PRACTICE • LEARN • GROW
Module 8 Final Quiz: Exception Handling MCQs
Solve topic-wise placement questions and improve your skills.
Module 8 Final Quiz: Exception Handling Progress
0 of 12 completed
0%
Topic Track
You are viewing MCQs in preview mode. Log in to select options, submit answers, and track your progress.
Log In to Answer
1
What keyword is used in C++ to signal that an error condition has occurred and transfer control out of normal execution?
A.
raise
B.
throw
C.
error
D.
panic
Explanation & Key
Correct Answer:
2
What happens when an exception is thrown inside a try block?
A.
Remaining code in the try block is skipped, and execution jumps straight to the first matching catch block
B.
The program finishes the try block and then enters catch
C.
The entire computer restarts
D.
All global variables are deleted
Explanation & Key
Correct Answer:
3
What is Stack Unwinding in C++ exception handling?
A.
Freeing heap memory with delete
B.
The automatic destruction of all local objects on the call stack between the throw point and the catch block
C.
Converting recursion into a while loop
D.
Clearing the CPU registers
Explanation & Key
Correct Answer:
4
Why should exceptions generally be caught by const reference (catch (const std::exception& e))?
A.
To avoid slicing polymorphic derived exception objects and avoid unnecessary copying
B.
Because C++ does not allow catching by value
C.
To allow the catch block to modify the exception
D.
It is required for compile-time speed only
Explanation & Key
Correct Answer:
5
What member function of std::exception returns a null-terminated explanation of the error?
A.
e.message()
B.
e.what()
C.
e.description()
D.
e.details()
Explanation & Key
Correct Answer:
6
Which standard exception is thrown when attempting to access vector elements beyond its size using vector::at()?
A.
std::bad_alloc
B.
std::out_of_range
C.
std::invalid_argument
D.
std::overflow_error
Explanation & Key
Correct Answer:
7
Which standard exception is thrown by 'new' when heap memory allocation fails?
A.
std::bad_alloc
B.
std::overflow_error
C.
std::null_pointer
D.
std::out_of_memory
Explanation & Key
Correct Answer:
8
How do you define a catch block that catches ANY exception type?
A.
catch (all)
B.
catch (...)
C.
catch (void*)
D.
catch (Exception e)
Explanation & Key
Correct Answer:
9
What happens if an exception is thrown and no matching catch block is found anywhere in the call hierarchy?
A.
The program resumes silently
B.
The runtime calls std::terminate(), abruptly aborting the program
C.
The operating system restarts the function
D.
The exception is converted into return 0
Explanation & Key
Correct Answer:
10
How do you create a custom exception class in C++?
A.
Inherit from std::exception and override what() const noexcept
B.
Write a function named error()
C.
Declare a struct with an int code
D.
Use #define EXCEPTION
Explanation & Key
Correct Answer:
11
What is the specifier 'noexcept' used for in modern C++?
A.
It forces the function to throw an exception
B.
It guarantees that a function will not throw an exception, enabling compiler optimizations (like move operations in vector)
C.
It disables return values
D.
It turns exceptions into warnings
Explanation & Key
Correct Answer:
12
What is the output of the following code snippet?
try {
throw 42;
} catch (int e) {
cout << "Caught: " << e;
}
A.
Caught: 42
B.
Caught: 0
C.
Unhandled exception crash
D.
Compilation Error
Explanation & Key
Correct Answer:
Question Palette
Answered
Current
Not Attempted
Wrong