Objects of each Class

Classic programmed-learning exercises, refreshed for modern Java and presented in the current MrStyner.com portfolio style.

Modern Java noteThis archive has been refreshed for Java 25 LTS. Core language concepts remain useful, while outdated setup instructions and browser-era Java are labeled or replaced. Java 26 is the current feature release; Java 25 is used here as the stable teaching baseline.

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 many more card classes and to create a well organized program. This was unthinkable not too many years ago. 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 10:

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