Skip to content
Sharp

Exceptions interview questions

try/catch/finally, filters, rethrowing, best practices.

3 questions with answers and explanations · 2 flashcards

Key ideas

  • finally always runs when control leaves the try (return, exception or normal exit).
  • Use throw; to rethrow and keep the original stack trace; throw ex; resets it.
  • Exception filters (catch (X e) when (...)) run *before* the stack unwinds.
  • Catch what you can handle, as specifically as possible; don't use exceptions for normal control flow.

Questions

  1. Type the exact output of this program.What does this code output?Hard
  2. Inside a catch (Exception ex) block, what's the difference between throw; and throw ex;?Multiple choiceMedium
  3. Which statements about exception handling in C# are true? Select all that apply.Select all that applyMedium