← 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?
- A.catch (const exception &) first, then catch (const out_of_range &)
- B.catch (const out_of_range &) first, then catch (const exception &)
- C.The order does not matter in C++
- 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 →