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

Answer:

Dear Henry,
Happy 12th Birthday

Dear Henry,
Happy 12th Birthday
How you have grown!!
Love, Alice

Top of the Hierarchy

The top class in a hierarchy is called the root of the hierarchy. The root of the hierarchy of cards is the class Card. A variable of the root type, Card, can be used with any of its descendants.

When a program uses several related objects, it is often useful to have a reference variable than can be used with any of them.


Card crd = new YouthBirthday( "Valerie", 7 );
crd.greeting();                                // print a youth birthday greeting

crd = new AdultBirthday( "Walter", 47 );
crd.greeting();                                // print an adult birthday greeting

crd = new Birthday( "Zoe", 30 );
crd.greeting();                                // print a generic birthday greeting

crd = new Holiday( "Kelly" );
crd.greeting();                                // print a holiday greeting

crd = new Valentine( "Jill", 42 );
crd.greeting();                                // print a valentine greeting

QUESTION 13:

(Thought Question: ) Say that you had a collection of 12 greeting card objects and wanted to keep them in an array. What type of array should you use?


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