🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: Exception Handling in C++: all 10 questions

Quiz: Exception Handling in C++ · Question 10 of 10

Why should a destructor never throw an exception?

Why should a destructor never throw an exception?

  1. A.Destructors cannot contain code
  2. B.Exceptions are not allowed in classes
  3. C.Destructors run during stack unwinding; a second exception at that moment terminates the program
  4. D.It would make the object live forever
Answer & explanation

Correct answer: Destructors run during stack unwinding; a second exception at that moment terminates the program

Destructors are noexcept by default, so a throw from one ends the program.

Can you get the rest right without peeking?

Take the timed Quiz: Exception Handling in C++ quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →