Vonique Leary wrote:
Is Mustang a Car or a Ford, or both???
Vonique Leary wrote:
And why would it be necessary for a Mustang to be a Car when the Ford object would have more details and specific methods in it. It seems as though Ford would be more useful since it already holds all the information that a Car holds, so why reference from a Car object?
|BSc in Electronic Eng| |SCJP 6.0 91%| |SCWCD 5 92%|
Is Mustang a Car or a Ford, or both???
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Henry Wong wrote:
FYI... the OP never showed us the class hierachy. We actually can't be sure if the assignment is valid or not.
Henry
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
OCPJP 6
BEE MBA PMP SCJP-6
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
By saying "Parent x = new Child1()" you are telling the compiler that for variable 'x' you
intend to use only those methods defined in Parent. Any extra methods that Child1 may
have are off limits. So the methods available are controlled by the variable type (Parent).
BEE MBA PMP SCJP-6
Consider Paul's rocket mass heater. |