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 / vasanth g

Here we are directly process method of class b.
so ans B that is 1st option....
consider this

static classA {
void process() throws Exception { throw new Exception(); }
}
static class B extends A {
void process() { System.out.println(&#65533;B &#65533;); }
}
public static void main(String[] args) {
A a=new B();
a.process();
}

in this program compilation fails at a.process
because compiler doen't know that reference a point on class
B where there's no exception. a is of A type and A's method
throws exception that isn't handled .a.process() enclosed in
try catch block.

Is This Answer Correct ?    4 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is a null check?

979


List types of storage classes in java?

1119


What is final class?

1004


What are the advantages of packages in java?

1545


What is the formula to calculate percentage?

998


5 Coding best practices you learned in java?

1005


what is the role of xml in core java?? and how we can use it?? can somebody give a sample program with explanation and from where i can read more about xml?????

2242


What are the main features of java?

948


Why collection doesn’t extend cloneable and serializable interfaces?

1078


What is the difference between choice and list?

1078


Can you give few examples of final classes defined in java api?

988


What are loops in java? What are three types of loops?

1014


What do you mean by flow of struts?

1295


What is the purpose of a volatile variable?

1012


How can we create objects if we make the constructor private ?

982