Given:
10. interface A { void x(); }
11. class B implements A { public void x() { } public
voidy() { } }
12. class C extends B { public void x() {} }
And:
20. java.util.List list = new java.util.ArrayList();
21. list.add(new B());
22. list.add(new C());
23. for (A a:list) {
24. a.x();
25. a.y();;
26. }
What is the result?
1 Compilation fails because of an error in
line 25.
2 The code runs with no output.
3 An exception is thrown at runtime.
4 Compilation fails because of an error in
line 20.
Answer Posted / neil
Compilation fails because of an error in
line 25.
| Is This Answer Correct ? | 44 Yes | 2 No |
Post New Answer View All Answers
Explain about main thread in java?
String and stringbuffer both represent string objects. Can we compare string and stringbuffer in java?
What is an immutable object?
Difference between string, string builder, and string buffer?
Is void a wrapper class?
what is object-oriented programming in java?
Which java version is latest?
What is a for loop in java?
What is fundamental datatype?
What does three dots mean in java?
What is the difference between a break statement and a continue statement?
What do you mean by stack?
What is a "pure virtual" member function?
What is java object name?
List the interfaces which extends collection interface?