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 / puneet khanna

You will need to have this for a basic reason that the
exceptions need to be caught and needed to be displayed if
your try block throws an exception say Array out of bound
exception which is a checked exception and you have only one
catch block which has the object of Exception class then
that Exception will be caught but you will not be able to
handle the particular array out of bound exception. so all
you need is to put all the exception in diff catch statement
which your try block may throw followed by the superclasses
of the exceptiontype subclasses .thus this is how you will
be able to handle each exception by its own way.

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How can u increase the heap size in the memory?

758


What is supplier in java?

748


Do we have pointers in java?

708


Is map ordered in java?

703


What do you mean by ternary operator in java?

773


How do I start learning java?

771


Is array a class?

703


If A Class Is Declared Without Any Access Modifiers, Where May The Class Be Accessed?

911


Why do we use variables?

693


Is the empty set a singleton?

704


How to change the priority of thread or how to set the priority of thread?

822


what do you mean by classloader?

736


What are the differences between this and super keyword?

731


What is the function of java?

724


Tell us something about different types of casting?

697