-1

Valentine, Holiday, and Birthday inherit from the class Card. In order for the following code to be correct, what type must the

Valentine, Holiday, and Birthday inherit from the class Card. In order for the following code to be correct, what type must the reference variable card be?

4/17/2019 12:32:27 AM

caldtone

1 Answer

New Answer

+1

It would be of type Card (coming from a Java perspective anyway) You can have class Card {...} and then the three other classes class Valentine extends Card {...} class Holiday extends Card {...} class Birthday extends Card {...} So if you then needed to refer to a Card object that isn’t three of the above, you would do Card c = new Card(); (assuming the classes have constructors in place) Your other three types can be declared as Valentine v = new Valentine(); Holiday h = new Holiday(); Birthday b = new Birthday(); and v, h and b can use methods from the Card class