Errors & Exceptions MCQs

5 MCQs  — Fundamental Programming MCQs

Practice Errors & Exceptions MCQs with correct answers and explanations. These questions are from the Fundamental Programming MCQs section.

In a C++ try block that can throw a Derived exception (where Derived inherits from Base), what is the correct order of catch blocks?
catch(Derived&) before catch(Base&), with catch(...) last
catch(...) first
catch(Base&) before catch(Derived&)
Order does not matter
When does the else block of a Python try/except/else statement run?
Only when finally is absent
Always
Only when the try block raised no exception
Only when an exception occurred
In C++, what happens when int a[5]; a[7] = 3; is executed?
The array automatically grows
Compilation error
std::out_of_range is thrown
Undefined behavior; there is no compile-time or runtime bounds check