Card 26 / 32: Given the following, 1. class X { void do1() { } } 2. class Y extends X { void do2() { } } 3. 4. class Chrome { 5. public static void main(String [] args) { 6. X x1 = new X(); 7. X x2 = new Y(); 8. Y y1 = new Y(); 9. // insert code here 10. } 11. } Which, inserted at line 9, will compile? (.)
A)
x2.do2();
B)
(Y)x2.do2();
C)
((Y)x2).do2();
D)
None of the above statements will compile.
Answer:
C) ((Y)x2).do2();
Previous Card | ← Previous Card Button |
Next Card | → Next Card Button |
Flip Card | Space-Bar |
|