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

Answer:

Not surprising. You must have got it from your abstract parents.

Holiday

Abstract classes are used to organize the "concept" of something that has several different versions in the children. An abstract class can include abstract methods and non-abstract methods.

Here is a class definition for class Holiday. It is a non-abstract child of an abstract parent:

class Holiday extends Card
{
  public Holiday( String r )
  {
    recipient = r; // recipient in Card is protected, so this works
  }

  public void greeting()
  {
    System.out.println("Dear " + recipient + ",");
    System.out.println("Season's Greetings!\n");
  }
}

The class Holiday is not an abstract class. Objects can be instantiated from it. Its constructor implicitly calls the no-argument constructor in its parent, Card, which calls the constructor in Object. So even though it has an abstract parent, a Holiday object is just as much an object as any other.


QUESTION 5:

Will each class that inherits from Card have a greeting() method?


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