What is the syntax for try catch finally statement?

To handle an exception we put code which might have exceptions in a try...catch statement.


try { 

// block of code to monitor for errors 


catch (ExceptionType1 exOb) { 

// exception handler for ExceptionType1 


catch (ExceptionType2 exOb) { 

// exception handler for ExceptionType2 



Program statements that might have exceptions are contained within a try block. The exception handler is coded using catch statement


Here, ExceptionType is the type of exception that has occurred.