Bird
Raised Fist0

What will be the output of the following C# code?

medium📝 Predict Output Q13 of Q15
C Sharp (C#) - Exception Handling
What will be the output of the following C# code?
try {
    Console.WriteLine("Start");
    throw new Exception();
} catch {
    Console.WriteLine("Caught");
} finally {
    Console.WriteLine("Finally");
}
AStart\nFinally
BStart\nCaught\nFinally
CCaught\nFinally
DStart\nCaught
Step-by-Step Solution
Solution:
  1. Step 1: Trace the try block

    "Start" is printed, then an exception is thrown.
  2. Step 2: Catch and finally execution

    The exception is caught, so "Caught" is printed, then the finally block runs printing "Finally".
  3. Final Answer:

    Start\nCaught\nFinally -> Option B
  4. Quick Check:

    try prints Start, catch prints Caught, finally prints Finally [OK]
Quick Trick: Remember: finally runs after catch even if exception thrown [OK]
Common Mistakes:
MISTAKES
  • Ignoring catch block output
  • Thinking finally runs before catch
  • Missing the exception thrown in try

Want More Practice?

15+ quiz questions · All difficulty levels · Free

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