A good answer might be:

Yes — by using an abstract class a programmer can make all children of that class look alike in important ways.

Not Everything in an abstract Class is abstract

Not everything defined in an abstract class needs to be abstract. The variable recipient is defined in Card and inherited in the usual way. However, if a class contains even one abstract method, then the class itself has to be declared to be abstract. Here is a program to test the two classes.

abstract class Card
{
  String recipient;
  public abstract void greeting();
}

class Holiday extends Card
{
  public Holiday( String r )
  {
    recipient = r;
  }

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

public class CardTester
{
  public static void main ( String[] args )
  {
    Holiday hol = new Holiday("Santa");
    hol.greeting();
  }
}

This is a complete, runable program. The urge to copy it to NotePad and get it running must be irresistable. Remember to call the file "CardTester.java" .


QUESTION 6:

Could you write this program without using an abstract class?