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
What is the use of http-tunneling in rmi?
Why we use multi threading instead of multiprocessing?
What is runtime polymorphism or dynamic method dispatch?
How does sublist works in java?
Which is easier netbeans or eclipse?
How many threads does a core java have?
Explain the key functions of data binding?
Is null or empty java?
What are different type of exceptions in java?
What is the symbol for line break?
How can you set an applet’s height and width as a percentage?
Is a boolean 1 bit?
How do you make an arraylist empty in java?
What is the synonym of procedure?
Explain jdk, jre and jvm?