0

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?

17th Apr 2019, 12:32 AM
caldtone
caldtone - avatar
6 Answers
+ 2
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
17th Apr 2019, 5:42 AM
Jenine
+ 2
the answer is "Card".
22nd Jan 2020, 3:05 AM
Faisal Dwi Rahmanto
Faisal Dwi Rahmanto - avatar
+ 1
card
1st Nov 2020, 5:15 PM
Lawretta Ekwia Addai Yeboah
Lawretta Ekwia Addai Yeboah - avatar
0
card
7th Jul 2020, 1:54 PM
ATTAMAH BENEDICT
ATTAMAH BENEDICT - avatar
0
The correct answer is: card
9th Mar 2021, 11:57 PM
Rusz Tamás
Rusz Tamás - avatar
0
the answer is "Card".
1st Jan 2022, 8:37 AM
M.I.M.Aqueel
M.I.M.Aqueel - avatar