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 / r.jainrocks@gmail.com
Compilation fails because of an error in
line 25.
because interface A has no method definition for method y()
....
| Is This Answer Correct ? | 9 Yes | 4 No |
Post New Answer View All Answers
What is a conditional equation?
Is string a class in java?
What is the purpose of abstract class?
What is difference between throw and throws ?
Why do we need data structure in java?
What are some examples of variable costs?
What is exception propagation?
What are the parts of methodology?
What is the Scope of Static Variable?
What will happen if a thrown exception is not handled?
When will you define a method as static in Java?
What is http client in java?
What about anonymous inner classes in java?
What is volatile data type?
Where is core java used?