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 is the largest long allowed by java?

781


How do you do absolute value in java?

731


What is the definition of tree ?

760


What do you mean by Hash Map and Hash Table?

808


Can constructor be inherited?

796


Why is java logo a cup of coffee?

824


What is abstract class? Explain

784


For class CFoo { }; what default methods will the compiler generate for you>?

843


Define immutable object?

843


What is the differences between c++ and java? Explain

812


What is javac_g?

764


Is object a data type in java?

849


What is the difference between abstract classes and interfaces?

790


Can we write method inside a method in java?

748


What is meant by oops concept in java?

739