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 parameter in simple terms?
What class of exceptions are generated by the java run-time system?
Can we write class inside a class in java?
What are runtime exceptions?
Why is stringbuffer called mutable?
What is the use of set in java?
Can java program run without jre?
What happens if I remove static from main method?
What's the purpose of static methods and static variables?
Is arraylist an object in java?
What is singleton math?
What is the order of arraylist in java?
Explain access modifiers in java.
What are access specifiers in java ?
How do you call a reference in java?