Tuesday, August 24, 2010

Interface extends another Interface

Courtesy of Sun Web Learning Center


 2. interface Picker { Integer tomato = 57; }
 3.
 4. interface Grinner {
 5.   int doStuff();
 6. }
 7.
 8. interface Sinner extends Picker, Grinner {
 9.   int doStuff(boolean maybe);
10.   int doStuff();
11. }

What is the result?


A All three interfaces will compile.
B Compilation fails due to multiple errors.
C Compilation fails due only to an error on line 2.
D Compilation fails due only to an error on line 8.
E Compilation fails due only to an error on line 9.
F Compilation fails due only to an error on line 10.

A is correct. It is legal for an interface to extend many interfaces, and it's okay to declare variables and overrides and overloads.

No comments:

Post a Comment