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
What are the benefits of operations in java?
What is == mean?
Explain the difference between the public, private, final, protected, and default modifiers?
Why destructor is not used in java?
Difference between operator overloading and function overloading
How will you reverse a link list without using recursion?
What access modifiers can be used for class ?
Mention some interfaces implemented by linked list in java.
Given a singly linked list, how will you print out its contents in the reverse order? Can you do it with consuming any extra space?
What is a variable analysis?
What are different types of control structures?
What is exception hierarchy in java?
What are the different types of sorting in java?
How many inner classes can a class have?
What is the maximum size of array in java?