Given:
interface A { public void aMethod(); }
interface B { public void bMethod(); }
& interface C extends A,B { public void cMethod(); }
class D implements B {
@ public void bMethod(){}
}
$ class E extends D implements C {
public void aMethod(){}
# public void bMethod(){}
public void cMethod(){}
}
What is the result?
A. Compilation fails because of an error in line &.
B. Compilation fails because of an error in line $.
C. Compilation fails because of an error in line #.
D. If you define D e = new E(), then e.bMethod() invokes the version of bMethod() defined in Line
@.
E. If you define D e = (D)(new E()), then e.bMethod() invokes the version of bMethod() defined in
Line @.
F. If you define D e = (D)(new E()), then e.bMethod() invokes the version of bMethod() defined in
Line #.
Execution:
There will be no compilation error in any line.
If we create object of some class and reference of it's base class then call some overrided method then it will only execute method of class object(new E()) rather then reference (D e).
Answer:
F. If you define D e = (D)(new E()), then e.bMethod() invokes the version of bMethod() defined in
Line 9.
interface A { public void aMethod(); }
interface B { public void bMethod(); }
& interface C extends A,B { public void cMethod(); }
class D implements B {
@ public void bMethod(){}
}
$ class E extends D implements C {
public void aMethod(){}
# public void bMethod(){}
public void cMethod(){}
}
What is the result?
A. Compilation fails because of an error in line &.
B. Compilation fails because of an error in line $.
C. Compilation fails because of an error in line #.
D. If you define D e = new E(), then e.bMethod() invokes the version of bMethod() defined in Line
@.
E. If you define D e = (D)(new E()), then e.bMethod() invokes the version of bMethod() defined in
Line @.
F. If you define D e = (D)(new E()), then e.bMethod() invokes the version of bMethod() defined in
Line #.
Execution:
There will be no compilation error in any line.
If we create object of some class and reference of it's base class then call some overrided method then it will only execute method of class object(new E()) rather then reference (D e).
Answer:
F. If you define D e = (D)(new E()), then e.bMethod() invokes the version of bMethod() defined in
Line 9.
No comments:
Post a Comment