Start Discovering Solved Questions and Your Course Assignments
TextBooks Included
Solved Assignments
Asked Questions
Answered Questions
explain the library javalangmath the java class library is huge we will not cover it all presently in fact the remaining eight classes will focus
write the hashcode method of javalangobjectanytime you override equals you should also override hashcode the hashcode method should ideally return
explain the equals methodthe equals method of javalangobject acts the similar as the operator that is it tests for object identity rather than
explain the methods of javalangobjectjavalangobject gives a number of methods that are general to all objects tostring is the most general such
describe the javalang package each package describes a number of classes exceptions interfaces and errors for instance in java 11 the javalang
why you dont need to import javalangthere is one exception to the import rule all classes in the javalang package are imported by default therefore
name conflicts when importing packagesit is possible which you will try to import a package which contains classes in which have the similar name as
describe importing classes in javafully qualified names such as javaneturl are not the most convenient thing to have to type you can use the shorter
give the example of using a class from the class library you use the javaneturl class only like youd use any other class along with these methods in
explain the reading documentation for a class in the class libraryfor instance lets suppose you need to use the url class in the javanet package
what is documentation for the class librarysun gives a large amount of documentation for the classes interfaces and exceptions in the class library
explain the javanet packageeach package describes a number of classes interfaces exceptions and errors for instance the javanet package contains
list the java class libraryjava holds an extensive library of pre-written classes you can use in your programs these classes are separated into
when should a method be staticbullneither reads from nor writes to example fields bullindependent of the state of the object bullmathematical methods
what is invoking static methodsif a method or field is declared static you access it through using the class name rather than a reference to a
give an example of class or static membersbelow is a car class along with such a speedlimit field and getspeedlimit method public class car private
describe the class or static members a method or a field in a java program could be declared static that means the member belongs to the class rather
explain the rules for tostring methods tostring methods should return a single line of text that does not contain any carriage returns or linefeeds
give a example of using tostring methods below is a version of cartest in which uses tostring and systemoutprintln instead of printing the fields in
describe tostring methods print methods are general in some languages but most java programs operate differently you can use systemoutprintln to
explain subclasses and polymorphism car and motorcycle are subclasses of motorvehicle if you instantiate a car or a motorcycle along with new you can
what are adding methodsa subclass isnt restricted to changing the behavior of its superclass it can also add fully latest techniques and fields that
explain overriding methods the solutionthe object oriented solution to this problem is to describe a new class call it slowcar that inherits from car
describe overriding methods assume that one day youve just finished your car class its been plugged into your traffic simulation that is chugging
what is multiple inheritance a few object oriented languages notably c permits a class to inherit from more than one unrelated class this is known as