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

why there are multiple catches for a try block.don't tell me
that there can be multiple exception of a code segment
that's why.tell me the real fact behind this.

Answer Posted / reshma

Multiple catch is necessory when the try when the try block
hase statements that raise different types of exceptions.

The single catch block will not be able to handle the
multiple error condition without complex coding. For
example close the database connection and closing of a file
For a particular exception closing of database connection
can be written in one catch block, for another kind of
exception we can close the file in another catch block.
That means if a file is opened and a database connection is
established, we want to release only one resourse at a time
for a particular exception.

When an exception is thrown it traverses through the catch
block until the matching catch block is found.

I hope my understanding is correct......

Is This Answer Correct ?    5 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Tell us something about different types of casting?

992


What is a map? What are the implementations of map?

1148


What is meant by memory leak?

1153


Explain the concept of proper inheritance?

1107


Can we define package statement after import statement in java?

1102


What are the features in java?

1121


What is the base class of all exception classes in java?

1105


What does i ++ mean in Java?

1001


Difference between final and effectively final ? Why is effectively final even required ?

1051


what is singleton class in java?

1113


What is the exact difference in between unicast and multicast object? Where we will use?

1041


What is exception hierarchy in java?

1073


What is difference between calling start() and run() method of thread?

1210


How to use Media tracker Class.

1174


What is field name?

1076