0
7.6kviews
Write a short note on Exception Handling Mechanism.
1 Answer
written 8.5 years ago by |
It provides two benefits. First, it allows us to fix the errors. Second, it prevents the program from automatically terminating. In order to take these two benefits Java has provided the mechanism of try-catch blocks. Its general form is as below:
try
{
// block of code to monitor for errors
}
catch (ExceptionType1 exOb)
{
// exception handler for ExceptionType1
}
catch (ExceptionType2 exOb)
{
// exception handler for ExceptionType2
}
//.......
Here, ExceptionType is the type of exception that has occurred and exOb.