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

Can a abstract class be declared final?

659


How do I get the | symbol on my keyboard?

677


What is google full form?

635


Is 0 an even number?

652


Explain about join() method?

639






what is the major difference between linkedlist and arraylist in java?

639


What is the difference between preemptive scheduling and time slicing?

695


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

636


What is meant by method overriding?

642


Explain working of call by reference function invoking.

685


Is static variable stored in heap?

592


What is static import?

701


What is a native method in java programming?

626


Define nashorn in java8.

668


Why do we need wrapper classes?

678