ACtE03 · Chapter 3Programming & Applications🏛️ Past Licensure QuestionID: f78b2572
In languages supporting structured exception handling with try-catch blocks (such as Java and C#), which code block is guaranteed to execute whether an exception is thrown, caught, or not thrown at all?
In languages supporting structured exception handling with try-catch blocks (such as Java and C#), which code block is guaranteed to execute whether an exception is thrown, caught, or not thrown at all?
Multiple Choice Options
- A✓ Correct Option
finally block
- B
throw block
- C
catch block
- D
try block
Detailed Technical Solution & Explanation
The finally block is executed unconditionally after try and catch blocks finish, ensuring deterministic execution of cleanup logic (such as closing database connections or files) regardless of whether an exception occurred.
Option Analysis:
•
Option A (finally block): Correct. Guarantees execution under all exit paths.
•
Option B (throw block): Raises an exception, does not act as a handler.
•
Option C (catch block): Executes only when a matching exception is thrown.
•
Option D (try block): May exit prematurely if an exception occurs.
Reference: Mock Test 04NEC Licensure Syllabus