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

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();
  }
}

Not everything defined in an abstract classes 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. At left is a program to test the two classes.

This is a complete runable program. I imagine the urge to copy it to NotePad and get it running is irresistable. Remember to call the file "CardTester.java" .


QUESTION 6:

Could this program have been written without using an abstract class?

Click Here after you have answered the question