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
How do listeners work?
Which class is used by server applications to obtain a port and listen for client requests?
Is list ordered in java?
How is java created?
How do you create immutable object in java?
Write code to implement bubble sort in java?
How can constructor chaining be done using this keyword?
Can we override the private methods?
Why is stringbuffer thread safe?
What is the full meaning of java?
What are the 8 data types in java?
Is empty .java file name a valid source file name?
Where are global variables stored?
What is anti pattern in java?
Is empty list java?