Can multiple catch blocks be executed for single try block?

  1. a. Yes

  2. b. No

  3. c. Under certain conditions

  4. d. May be


Correct Option: B

AI Explanation

To answer this question, you need to understand how try-catch blocks work in programming.

In general, when an exception is thrown within a try block, the program jumps to the corresponding catch block that can handle that exception. Once the catch block is executed, the program continues with the code after the catch block.

In the case of multiple catch blocks, only one catch block will be executed for a single try block. The catch block that is executed will be the first catch block that matches the type of the exception thrown. Once that catch block is executed, the program will not execute any subsequent catch blocks.

Therefore, the correct answer is:

B. No - Multiple catch blocks cannot be executed for a single try block.

Find more quizzes: