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 5 boolean operators?
Explain the selection sort algorithm and state its time complexity?
What is regex in java?
What is the Concept of Encapsulation in OOPS
How to Sort Strings which are given in List and display in ascending order without using java api.
What restrictions are placed on method overloading?
What is difference between variable declaration and definition?
What is a protected method?
os is developed in c no java is more secured then c na why dont the os developed is developed using java
What is java virtual machine and how it is considered in context of java’s platform independent feature?
What data structures are used to perform recursion?
What is the implementation of destroy method in java. Is it native or java code?
How do you use compareto method?
In java, how many ways you can take input from the console?
Can we assign integer value to char in java?