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


Please Help Members By Posting Answers For Below Questions

How many bits is a char?

531


Is alive method in java?

500


What are exception handling keywords in java?

599


Make a data structure and implement an algorithm to print all the files in a directory. (The root directory can have sub-directories too.)

845


Why javac is not recognized?

513






What is a local, member and a class variable?

570


Does java allow default arguments?

586


how do I create a runnable with inheritance? : Java thread

501


What is constant in programming?

550


Which graphs are functions?

488


What is the symbol for line break?

596


Differentiate between vector and array list.

622


What is application system?

497


Is it possible to instantiate the abstract class?

534


Which is better singleton or static class?

499