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

Answer:

Yes. The abstract Card class can be used as a model of what each new type of card should look like.


Objects of each Class

cards descending from card

By using hierarchical organization and inheritance it is easy to add more card classes and to create a well-organized program. Here is a sample run of this program:

Your name:
Sue
Dear Sue,
Season's Greetings!

Dear Sue,
Happy 21th Birthday

Dear Sue,
Love and Kisses,
XXXXXXX

When the main() method has constructed its three objects, the situation is as in the picture. There are three classes that can be instantiated, and one object of each class has been instantiated. Of course, as many objects as you need of each type (except Card) can be instantiated.


QUESTION 13:

There are 4 classes. Why can only 3 be instantiated?


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