The statements inside ______ block are always executed whether an exception has occured in the try block or not.
The statements inside ______ block are always executed whether an exception has occured in the try block or not.
Solution
The finally block is always executed, whether or not the try block raised an exception, and whether or not it was handled. It is used for clean-up work such as closing files or releasing resources.
Except (Option 1): runs only when an exception occurs in the try block, and only if its type matches.
Catch (Option 2): this is the keyword in Java and C++ for handling exceptions, and it also runs only when an exception occurs. Python uses except instead.
Assert (Option 4): a statement that checks a condition and raises AssertionError if it is false. It is not a block that always runs.
Related questions:
2025: 3 June Shift 2
2026: 11 May Shift 2
2025: 20 May Shift 1
2026: 23 May Shift 1