Bird
0
0

Consider this code:

medium📝 Predict Output Q5 of 15
C Sharp (C#) - Exception Handling
Consider this code:
try {
    Console.WriteLine("Start");
    return;
} finally {
    Console.WriteLine("Cleanup");
}
What is the output when this method is called?
ACleanup
BStart
CStart Cleanup
DNo output
Step-by-Step Solution
Solution:
  1. Step 1: Analyze try block with return

    "Start" is printed, then return is called.
  2. Step 2: finally block runs before return

    Before method exits, finally prints "Cleanup".
  3. Final Answer:

    Start Cleanup -> Option C
  4. Quick Check:

    finally runs even after return = A [OK]
Quick Trick: finally runs before method exits even after return [OK]
Common Mistakes:
MISTAKES
  • Assuming return skips finally
  • Expecting only Cleanup output
  • Thinking no output prints

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More C Sharp (C#) Quizzes