It is a process of stopping the abnormal termination of a program whenever an exception occur and execute the code that is not related with exception.
Handling an Exception :
If we want to handle an exception code has to enclosed under some special blocks known as try, catch blocks. Which has to used as following
Syntax :
try
{
--statements which will cause an exception
-- statements which should not be executed when an exception occurs.
}
catch(<exception> <var>)
{
-- Statements which should be executed only when an exceptions occurs
}
--- < Multiple catch blocks of required >--
Handling an Exception :
If we want to handle an exception code has to enclosed under some special blocks known as try, catch blocks. Which has to used as following
Syntax :
try
{
--statements which will cause an exception
-- statements which should not be executed when an exception occurs.
}
catch(<exception> <var>)
{
-- Statements which should be executed only when an exceptions occurs
}
--- < Multiple catch blocks of required >--