|
A good answer might be:
Dear Valerie, Happy 7th Birthday How you have grown!! |
Using PolymorphismAssume that AdultBirthday has been defined. It will look much like YouthBirthday but with a slightly different birthday message. Here is a program fragment (part of main() in another class): It will write out:AdultBirthday ab = new AdultBirthday( "Walter", 47 ); ab.greeting(); Now inspect the following code:Dear Walter, Happy 47th Birthday You haven't changed at all! Card crd = new YouthBirthday( "Valerie", 7 ); crd.greeting(); crd = new AdultBirthday( "Walter", 47 ); crd.greeting(); crd = new Birthday( "Zoe", 30 ); crd.greeting(); |
QUESTION 9:Is this code correct? Can crd be used for each of the three objects? Click Here after you have answered the question |