CBSE Class 12 Computer Science Question 4 of 30

Exception Handling — Question 4

Back to all questions
4
Question

Question 4

Assertion (A): No matter what exception occurs, you can always make sure that some common action takes place for all types of exceptions.

Reasoning (R): The finally block contains the code that must execute.

  1. Both A and R are true and R is the correct explanation of A.
  2. Both A and R are true but R is not the correct explanation of A.
  3. A is true but R is false.
  4. A is false but R is true.
Answer

Both A and R are true and R is the correct explanation of A.

Explanation
The 'finally' block contains code that must execute, irrespective of whether an exception is raised. This ensures that some common action takes place for all types of exceptions, no matter which exception occurs.