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

Answer:

As many as your application needs.


Three Variables, Three Objects

three holiday cards







Here is another testing program. It instantiates several cards, using a different variable to refer to each as it is constructed.


public class CardTester
{
  public static void main ( String[] args )
  {
    Holiday card01 = new Holiday("Santa");
    card01.greeting();
    
    Holiday card02 = new Holiday("Tinkerbell");
    card02.greeting();
    
    Holiday card03 = new Holiday("Elvis");
    card03.greeting();
  }
}

The program outputs:

Dear Santa,
Season's Greetings!

Dear Tinkerbell,
Season's Greetings!

Dear Elvis,
Season's Greetings!

QUESTION 8:

Could you write the main() program using only one reference variable?


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