InterviewSolution
| 1. |
What Are Multiple Catch Blocks? |
|
Answer» There MIGHT be a case when a code enclosed with in a try block throws more than one exception. To handle these types of situations, two or more catch clauses can be specified where each catch clause catches a DIFFERENT type of exception. When an exception is thrown, each of the catch statement is INSPECTED in order, and the FIRST one whose type matches that of the thrown exception is executed. int a[] = {0}; There might be a case when a code enclosed with in a try block throws more than one exception. To handle these types of situations, two or more catch clauses can be specified where each catch clause catches a different type of exception. When an exception is thrown, each of the catch statement is inspected in order, and the first one whose type matches that of the thrown exception is executed. int a[] = {0}; |
|