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...

11. static class A {
12. void process() throws Exception { throw new Exception();
}
13. }
14. static class B extends A {
15. void process() { System.out.println(”B”); }
16. }
17. public static void main(String[] args) {
18. new B().process();
19. }
What is the result?
1 B
2 The code runs with no output.
3 Compilation fails because of an error in
line 12.
4 Compilation fails because of an error in
line 15.

Answer Posted / bhanu

hi,

Keep the whole code in a class
Ex:
class Sample
{
.....
..... //the above code
.....
.....
}

Now it will not give any error while compilation.
It is the concept of static nested classed
Thank you

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

how to handle exceptions in ejb?

2294


How does enum work in java?

1001


List some important features of java 10 release?

1053


What is function and its uses?

1091


What is equlas() and hashcode() contract in java? Where does it used?

1109


What is ctrl m character?

1039


What are the two ways in which thread can be created?

1036


What are the different data types in java?

983


What are the basic interfaces of java collections framework?

1101


What is instance example?

935


Write a java program to check if a number is prime or not?

1027


Which data type is class in java?

999


List implementations of list interface?

1021


If I only change the return type, does the method become overloaded?

914


What are static methods?

1026