Yes. Since the child did not define a method with the same signature and same return type as the parent, it must be declared to be abstract. It is OK to have an abstract child of an abstract parent.
Let us use the hierarchy of classes used in the previous chapter
to illustrate these ideas.
The diagram shows that the class Card
is an abstract class
(which, therefore, cannot be instantiated.)
Card
has a single abstract method, greeting()
.
The other three classes are ordinary classes which can be instantiated.
They inherit from Card
, so each must define a greeting()
method which is not abstract.
(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?