Question 8
interface C {
char w = DD.echo('w');
char x = DD.echo('x');
}
interface D extends C {
char y = DD.echo('y');
char z = DD.echo('z');
char a = DD.echo(w);
}
class DD implements D {
static char echo(char c) {
System.out.print(c);
return c;
}
public static void main (
String[] args) {
System.out.print("Main");
DD dd = new DD();
System.out.println(a);
}
}
What is the result of attempting to compile and run the above program?
a. Prints: yzwMain
b. Prints: Mainyzw
c. Prints: wxyzwMain
d. Prints: Mainwxyzw
e. Prints: yzwxwwMain
f. Prints: Mainyzwxww
g. Runtime Exception
h. Compiler Error
i. None of the Above
The answer is D here.. i'm wondering why dont the interface variables get initialized unless explicitly called.. becoz interfaces are also implitly static and once they are loaded they should be intialized?? Whats the deal here!