Is it possible that one try block can have multiple catch blocks?

There can be more than one exception handler (or catch block) for one try block, because it might so happen that in one single try block there can be different types of exceptions that can be thrown. 

This is shown in the following code snippet:
try
{
// statement that throws divide-by-zero exception
// statement that throws array out-of-bound exception
}
catch ( divide_error id1 ){ // code }
catch ( out_of_bound_error id2 ){ // code } 

No comments:

Post a Comment