What is the result?

Given:
1. interface A { public void aMethod(); }
2. interface B { public void bMethod(); }
3. interface C extends A,B { public void cMethod(); }
4. class D implements B {
5. public void bMethod(){}
6. }
7. class E extends D implements C {
8. public void aMethod(){}
9. public void bMethod(){}
10. public void cMethod(){}
11. }

What is the result?

Given:
1. interface A { public void aMethod(); }
2. interface B { public void bMethod(); }
3. interface C extends A,B { public void cMethod(); }
4. class D implements B {
5. public void bMethod(){}
6. }
7. class E extends D implements C {
8. public void aMethod(){}
9. public void bMethod(){}
10. public void cMethod(){}
11. }

What is the result?

A.
Compilation fails because of an error in line 7.

B.
Compilation fails because of an error in line 3.

C.
If you define D e = (D)(new E()), then e.bMethod() invokes the version of bMethod() defined in
Line 5.

D.
Compilation fails because of an error in line 9.

E.
If you define D e = new E(), then e.bMethod() invokes the version of bMethod() defined in Line
5.

F.
If you define D e = (D)(new E()), then e.bMethod() invokes the version of bMethod() defined in
Line 9.



Leave a Reply 0

Your email address will not be published. Required fields are marked *