Difficulty: Easy
Correct Answer: ACD
Explanation:
Introduction / Context:
This question tests control flow through try/catch/finally when no exception occurs. The finally block always executes, regardless of whether an exception is thrown or caught.
Given Data / Assumptions:
Concept / Approach:
No exception is thrown, so the catch block is skipped. The finally block executes and then control continues after the try/catch/finally.
Step-by-Step Solution:
Verification / Alternative check:
Add a throw in badMethod() and see how the flow changes (catch would run, but finally still runs).
Why Other Options Are Wrong:
"AC" misses the final "D"; "ABCD" would require an exception that is caught (printing "B"), which does not happen.
Common Pitfalls:
Thinking finally is conditional; forgetting the last print after the try/catch/finally.
Final Answer:
ACD
Discussion & Comments