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

what state does a thread enter when it terminates its processing? : Java thread

608


Name four container classes.

563


What is complexity and its types?

534


How do you declare a variable?

634


Is static variable stored in heap?

513






Is null a string?

562


How do you implement tree mirroring in java?

599


What are different types of control structures?

495


What is a boolean expression in java?

543


What is java util function?

522


What is the purpose of the main method?

549


What is a substitution variable?

571


Is integer passed by reference in java?

576


What is fail first in java?

585


What carriage return means?

534