What is “try and catch” in java

Answer Posted / lakshay gupta

The statements within the try block are executed, and if any
of them throws an exception, execution of the block is
discontinued and the exception is handled by the catch
block. There may be multiple catch blocks, in which case the
first block with an exception variable whose type matches
the type of the thrown exception is executed.
If no catch block matches the type of the thrown exception,
the execution of the outer block (or method) containing the
try ... catch statement is discontinued, and the exception
is passed up and outside the containing block (or method).
The exception is propagated upwards through the call stack
until a matching catch block is found within one of the
currently active methods. If the exception propagates all
the way up to the top-most main method without a matching
catch block being found, a textual description of the
exception is written to the standard output stream.

Is This Answer Correct ?    5 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What does s mean in regex?

790


Explain 5 io best practices?

819


What is a static method in java?

786


Can singleton class be serialized?

743


What is data type modifier?

729


Can you call a method on a null object?

784


What do you understand by java?

768


Can a top level class be private or protected?

803


What are java methods?

820


What is variable in java?

741


What is the difference between heap and stack memory?

910


What does a method signature consist of?

736


Explain the inheritance?

782


How do you check if a character in a string is a digit or letter?

817


Explain the private field modifier?

860