Given:
interface Event {
String type = “Event”;
public void details();
}
class Quiz {
static String type = “Quiz”;
}
public classPracticeQuiz extends Quiz implements Event {
public void details() {
System.out.print(type);
}
public static void main(String[] args) {
new PracticeQuiz().details();
System.out.print(” ” + type);
}
}
What is the result?
A.
Event Quiz
B.
Event Event
C.
Quiz Quiz
D.
Quiz Event
E.
Compilation fails
I think the answer has to be E, because System.out.print(type);// The field type is ambiguous
I know certainly, E is correct.
You’re right.
E is the correct answer.
The field type is AMBIGUOUS !!!
Tested in Eclipse !!! 😀
+1
E. Compilation fails
System.out.print(type);// The field type is ambiguous
System.out.print(” ” + type);// The field type is ambiguous
I agree, E is correct.
Because a field in interface is final static.
+1
+1
e