All of them.

Abstract Methods

In this example, each card class has its own version of the greeting() method. Each class has a greeting(), but each one is implemented differently. It is useful to put an abstract greeting() method in the parent class. This says that each child inherits the "idea" of greeting(), but each implementation is different. Here is the class definition of the abstract class Card:

abstract class Card
  String recipient;                 // name of who gets the card
  public abstract void greeting();  // abstract greeting() method

This is the complete definition of this abstract class. Notice the abstract method. Abstract classes can (but don't have to) contain abstract methods. Also, an abstract class can contain non-abstract methods, which will be inherited by the children.

An abstract method has no body. (It has no statements.) It declares an access modifier, return type, and method signature followed by a semicolon. A non-abstract child class inherits the abstract method and must define a non-abstract method that matches the abstract method.

An abstract child of an abstract parent does not have to define non-abstract methods for the abstract signatures it inherits. This means that there may be several steps between an abstract base class to a child class that is completely non-abstract.

Since no constructor is defined in Card the default no-argument constructor is automatically supplied by the compiler. However, this constructor cannot be used directly because no Card object can be constructed.


Are you feeling a bit abstract right now?