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 difference between the jdk 1.02 event model and the event-delegation model introduced with jdk 1.1?
What is the difference amongst jvm spec, jvm implementation, jvm runtime ?
What are disadvantages of java?
Does treeset allow null in java?
What is stack class in java?
What will happen if there is a default method conflict as mentioned above and we have specified the same signature method in the base class instead of overriding in the existing class ?
How do you compare two strings lexicographically?
What is compareto?
Can you extend main method in java?
when should you use stringbuilder class in a program?
What is meant by local variable and instance variable?
Difference between arraylist and hashset in java?
What flag up means?
Why java is not 100% object-oriented?
What are the different http methods?