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 class forname used for?
What is the purpose of a volatile variable?
What is a line separator in java?
What is instanceof keyword?
Is integer passed by reference in java?
What is r in java?
What is a JAR file?
What is Java Reflection API? Why it’s so important to have?
What is a char in java?
Why is java called the platform independent programming language?
What was java originally called?
Is there a sort function in java?
Is java a digit method?
How does hashset works in java?
Can you access the private method from outside the class?