Start Discovering Solved Questions and Your Course Assignments
TextBooks Included
Active Tutors
Asked Questions
Answered Questions
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
explain what is multilevel inheritance the car-motorcycle-motorvehicle instances showed single-level inheritance theres nothing to stop you from
describe the superclass in inheritance in this example you start through defining a more common motorvehicle class public class motorvehicle private
what is inheritance in java explain with examplecode reusability is claimed to be a key advantage of object-oriented languages over
what is operator overloadinga few object oriented languages notably c permit you to not only overload techniques but also operators like or - this
explain what is constructors it is frequent the case in which overloaded techniques are essentially the similar except that one supplies default
what is overloading explain with an exampleoverloading is while the similar method or operator can be used on several different kinds of data for
implement the money class discussed in class this class should represent a dollar and cents amount with 0-99 cents and the cents being the same sign
what should be public what should be privateas a rule of thumbclasses are public fields are private constructors are public getter and setter methods
how we can changing the implementation suppose the car class requires to be used in a simulation of new york city traffic in that each actual car on
explain the three benefits of access protection access protection has three major benefits 1it permits you to enforce constraints on an objects state
describe the four levels of access protection any two various java objects have one of four relations to each other the four relations are bullthe
give an examples of access protection this is how the car class would almost certainly be written in practice remember that all the fields are now
describe about the term access protection global variables are a typical cause of bugs in most programming languages a few unknown function can
what is constraints explain with exampleone of the purposes to use constructors and setter techniques rather than directly accessing fields is to