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.

Answers were Sorted based on User's Feedback



Given: 10. interface A { void x(); } 11. class B implements A { public void x() { } public voidy..

Answer / neil

Compilation fails because of an error in
line 25.

Is This Answer Correct ?    44 Yes 2 No

Given: 10. interface A { void x(); } 11. class B implements A { public void x() { } public voidy..

Answer / pankaj malik

Compilation Error will be thrown at line 23 :
Type Mismatch: cannot convert from elemnt type Object to A.

Is This Answer Correct ?    9 Yes 0 No

Given: 10. interface A { void x(); } 11. class B implements A { public void x() { } public voidy..

Answer / 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

More Core Java Interview Questions

Which programming language is best in future?

0 Answers  


What does flagged out mean?

0 Answers  


What are format specifiers in java?

0 Answers  


What is the method overriding?

0 Answers  


What is string subsequence method?

0 Answers  






How do you escape in java?

0 Answers  


what is the difference between applet and swing and gui application in java . What we do with the collections set and list interface

2 Answers   CTS, Phoenix Technologies,


Hi i am creating desktop application in that i want calling to mobile number. i have java telephone api (JTAPI) but i dont understand how it configure & use plese help me

0 Answers  


What is final keyword?

0 Answers  


23. Storage space in java is of the form Stack Queue Heap List 24. What is java code embedded in a web page known as Applets Servlets scriptlets snippets 25. Which of the following attributes are compulsory with an <applet> tag?. code,height & width. 26. What does 'CODEBASE' in an applet tag specify?. Files absolute path.

0 Answers   TCS,


When will we use them?

0 Answers  


Which package is imported by default?

0 Answers  


Categories