Difficulty: Easy
Correct Answer: finally exception finished
Explanation:
Introduction / Context:
This Java question tests understanding of exception flow with try, finally, and catch in different call frames. It highlights that the finally block always executes, even when an exception is thrown and later caught in the caller.
Given Data / Assumptions:
Concept / Approach:
In Java, a finally block runs after try (and optional catch) completes, regardless of whether an exception is thrown. If an exception is not handled in the current method, it propagates outward, but the current method's finally still executes first.
Step-by-Step Solution:
Verification / Alternative check:
Comment out the catch in main to see the difference: you would still see "finally " before the program terminates with an uncaught exception.
Why Other Options Are Wrong:
Common Pitfalls:
Assuming finally runs only if no exception is thrown; or assuming catch in main prints before the callee's finally.
Final Answer:
finally exception finished
Discussion & Comments