Sunday, September 18, 2011

Quiz of the day | OCPJP (13)

2. class Parent {
3. static String parent = "";
4. void doStuff() { parent += "parent "; }
5. }
6. public class Child extends Parent {
7. public static void main(String[] args) {
8. new Child().go();
9. }
10. void go() {
11. Parent p = new Child();
12. Child c = (Child)p;
13. // insert code here
14. }
15. void doStuff() { parent += "child "; }
16. }


If the rest of the code compiles, which line(s) of code, inserted independently at line 13, compile? (Choose all that apply.)

A. c.doStuff();
B. p.doStuff();
C. this.doStuff();
D. super.doStuff();
E. c.super.doStuff();
F. p.super.doStuff();
G. this.super.doStuff();
H. There are other errors in the code.


DOWNLOAD the answer

0 comments: