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

Explain where variables are created in memory?

588


Explain the protected field modifier?

598


What method is used to specify a container's layout in java programming?

550


Can a java program have 2 main methods?

554


How do you compare objects in java?

505






Tell me a few examples of final classes defined in Java API?

570


What is the preferred size of a component in java programming?

545


How to calculate the length of a singly linked list in java?

589


What is main string [] args?

524


What is module with example?

516


Can we extend private class in java?

553


Why do we need array in java?

537


What are loops in java?

555


How many java versions are there?

566


What happens when a thrown exception is not handled?

584