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

Answer:

Dear Amy,
Season's Greetings!

Dear Bob,
Love and Kisses,
XXX

Dear Cindy,
Happy 17th Birthday

Descendants

What types of objects can a reference variable refer to?

A variable can hold a reference to an object whose class is a descendant of the class of the variable.

A descendant of a class is a child of that class, or a child of a child of that class, and so on. Siblings are not descendants of each other (you did not inherit anything from your brother, thank goodness.)

Note: there are some complications to this rule which are not covered here. You will probably never need to know them.


QUESTION 17:

Here are some variable declarations:

Card      c;
Birthday  b;
Valentine v;
Holiday   h

Which of the following are correct? (click on the statement to confirm your answer)

c = new Valentine("Debby", 8);

b = new Valentine("Elroy", 3);

v = new Valentine("Fiona", 3);

h = new Birthday ("Greg",  35);


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