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 the purpose of declaring a variable as final?
Is set sorted in java?
What is nullpointerexception in java?
Explain about the performance aspects of core java?
Name few java 8 annotations ?
What are keywords and reserved words in java?
What is the concatenation operator in java?
How do you sort an array in java?
When would you use a static class?
What is java thread dump, how can we get java thread dump of a program?
What is tochararray in java?
Explain the importance of thread scheduler in java?
What are the six ways to use this keyword?
What are the data types supported by java? What is autoboxing and unboxing?
How do you add an element to an arraylist in java?