Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


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

Can an interface be final?

0 Answers  


What is time complexity algorithm?

0 Answers  


How to implement a multithreaded applet?

0 Answers  


describe method overloading

0 Answers  


How to stop a thread in java? Explain about sleep () method in a thread?

0 Answers  


What is local class in java?

0 Answers  


What happens if a constructor is declared private?

0 Answers  


How do I convert a numeric ip address like 192.18.97.39 into a hostname like java.sun.com?

0 Answers  


Why hashset is used in java?

0 Answers  


Write a function to print Fibonacci series and Tribonacci series?

0 Answers   Hexaware,


Where are variables stored?

0 Answers  


Can we have more than one package statement in the source file?

0 Answers  


Categories