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.

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

What is the default value of float and double datatype in java?

967


What is double checked locking in singleton?

1014


how to create daemon thread in java?

1021


What is finally in Java?

1026


What is a variable simple definition?

984


Does java trim remove newline?

936


What are reference variables in java?

1090


What is array list in java?

1033


Which oo concept is achieved by using overloading and overriding?

965


Can a final variable be null?

971


Wha is the output from system.out.println(“hello”+null); ?

1096


How do you override a private method in java?

938


What steps are taken when the OS shifts from one-thread execution to another?

1327


Which collection is best for sorting in java?

1079


How do you check if two strings are equal in java?

975