Card 25 / 32: public class Dog { } public class Beagle extends Dog{ } public class Kennel { public static void main(String[] args) { Beagle b1 = new Beagle(); Dog dog1 = new Dog(); Dog dog2 = b1; // insert code here //line-9 } } Which, inserted at line 9, will compile? (.)
A)
Beagle b2 = (Beagle) dog1;
B)
Beagle b3 = (Beagle) dog2;
C)
Beagle b4 = dog2;
D)
None of the above statements will compile
Answer:
A) Beagle b2 = (Beagle) dog1;
B) Beagle b3 = (Beagle) dog2;
Previous Card | ← Previous Card Button |
Next Card | → Next Card Button |
Flip Card | Space-Bar |
|