🎙 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 6 of 10

Which catch block order is correct?

Which catch block order is correct?

  1. A.catch (const exception &) first, then catch (const out_of_range &)
  2. B.catch (const out_of_range &) first, then catch (const exception &)
  3. C.The order does not matter in C++
  4. D.catch (...) first, then the specific types
Answer & explanation

Correct answer: catch (const out_of_range &) first, then catch (const exception &)

The first matching handler wins, so a base-class handler placed first would hide every derived handler after it.

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 →