Arrange the following steps of handling exceptions:
A. An error encountered in a method
B. Create exception object and exception is raised
C. Runtime system searches for exception handler in the current method
D. Catching an exception
Arrange the following steps of handling exceptions:
A. An error encountered in a method
B. Create exception object and exception is raised
C. Runtime system searches for exception handler in the current method
D. Catching an exception
Solution
A. An error encountered in a method
B. Create exception object and exception is raised
C. Runtime system searches for exception handler in the current method
D. Catching an exception
The error occurs first, the method creates and throws an exception object, the runtime then searches for a handler (starting with the current method), and the handler finally catches it.
Option 1: the runtime can search for a handler only after the exception object has been created and thrown, so B comes before C.
Option 3: an exception object cannot be created before an error has occurred, so A comes first.
Related questions:
2026: 31 May Shift 1
2026: 18 May Shift 2
2025: 16 May Shift 1