go to previous page   go to home page   go to next page

Answer:

Yes. Since the child did not define a method with the same signature and same return type as the parent, it did not override the parent's abstract method. So the child contains an abstract method and must be declared to be abstract. It is OK to have an abstract child of an abstract parent.


Card Hierarchy

card hierarchy

Here are the classes used in the previous chapter. Card is an abstract class (so, therefore, cannot be instantiated.)

Card has a single abstract method, greeting(). The other three classes are ordinary classes which inherit from Card. Each must define a greeting() method which is not abstract.


QUESTION 5:

(Review: ) Say that a method is invoked as here:

referenceVariable.greeting()

What determines which method is run? The class of the reference variable or the class of the object it points to?


go to previous page   go to home page   go to next page