Exception Handling In C Plus Plus — Part 1 MCQs with Explanations
Practice high-yield Programming & Software Development MCQs on Exception Handling In C Plus Plus — Part 1 with worked academic solutions for FPSC, PPSC, NTS, NITB, PTS.
Questions
40
Difficulty Level
Exam-Level
Target Exams
FPSC, PPSC, NTS...
Estimated Time
48 mins
Exam-Level FPSC PPSC NTS NITB PTS
Verified for Commission Syllabus • Oct 14, 2026
40
Verified Practice Questions
Interactive test mode with detailed academic worked solutions
Live Progress|0/40 answered
✓0 correct
✗0 wrong
0% score
🎉 Set complete! All 40 questions answered.
Question 1 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
How do you specify that a function may throw an exception in C++?
Correct Answer: Option D — Using the 'noexcept' specifier
Detailed Academic Explanation:
The correct answer is Option D: Using the 'noexcept' specifier Here's why: Exception handling in C++ allows you to deal with unexpected problems that occur during the execution of a program. A function can signal that something went wrong by "throwing" an exception. Let's break down the options: Option A: Using the 'throws' keyword - The `throws` keyword is not used in standard C++ for specifying exceptions. Languages like Java use `throws`. Option B: Using the 'exception' keyword - The `exception` keyword is related to exception classes but not to specifying if a function *might* throw an exception. Option C: Using the 'throws()' specifier - This is also incorrect. C++11 introduced `noexcept` for this purpose. Older C++ standards used something called exception specifications but they are largely deprecated and not the best practice to use anymore. Option D: Using the 'noexcept' specifier - The `noexcept` specifier is used to specify whether a function may throw an exception. If a function is declared `noexcept`, it promises *not* to throw any exceptions. If it *does* throw an exception, the program might terminate abruptly. The absence of `noexcept` does *not* mean the function *will* throw, only that it *might*.
💡Key Conceptual Anchor:Exception Handling In C Plus Plus
Question 2 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is exception handling in C++?
Correct Answer: Option A — A method to handle errors during runtime
Detailed Academic Explanation:
A method to handle errors during runtime is the correct answer to “What is exception handling in C++”. This question is standard in competitive examination syllabi for Exception Handling In C Plus Plus.
💡Key Conceptual Anchor:Exception Handling In C Plus Plus
Question 3 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which keyword is used to throw an exception in C++?
Correct Answer: Option B — throw
Detailed Academic Explanation:
throw is the correct answer to “Which keyword is used to throw an exception in C++”. This question is standard in competitive examination syllabi for Exception Handling In C Plus Plus.
💡Key Conceptual Anchor:Exception Handling In C Plus Plus
Question 4 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the purpose of the 'try' block in exception handling in C++?
Correct Answer: Option C — To define the block of code that may generate exceptions
Detailed Academic Explanation:
To define the block of code that may generate exceptions is the correct answer to “What is the purpose of the 'try' block in exception handling in C++”. This question is standard in competitive examination syllabi for Exception Handling In C Plus Plus.
💡Key Conceptual Anchor:Exception Handling In C Plus Plus
Question 5 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of the following is not a standard exception class in C++?
Correct Answer: Option A — IOException
Detailed Academic Explanation:
IOException is the correct answer to “Which of the following is not a standard exception class in C++”. This question is standard in competitive examination syllabi for Exception Handling In C Plus Plus.
💡Key Conceptual Anchor:Exception Handling In C Plus Plus
Question 6 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the purpose of the 'catch' block in exception handling in C++?
Correct Answer: Option C — To catch and handle exceptions
Detailed Academic Explanation:
To catch and handle exceptions is the correct answer to “What is the purpose of the 'catch' block in exception handling in C++”. This question is standard in competitive examination syllabi for Exception Handling In C Plus Plus.
💡Key Conceptual Anchor:Exception Handling In C Plus Plus
Question 7 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of the following is not a part of the exception handling mechanism in C++?
Correct Answer: Option C — assert function
Detailed Academic Explanation:
assert function is the correct answer to “Which of the following is not a part of the exception handling mechanism in C++”. This question is standard in competitive examination syllabi for Exception Handling In C Plus Plus.
💡Key Conceptual Anchor:Exception Handling In C Plus Plus
Question 8 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What does the 'std::exception' class represent in C++ exception handling?
Correct Answer: Option A — It is a base class for all standard C++ exceptions
Detailed Academic Explanation:
It is a base class for all standard C++ exceptions is the correct answer to “What does the 'std::exception' class represent in C++ exception handling”. This question is standard in competitive examination syllabi for Exception Handling In C Plus Plus.
💡Key Conceptual Anchor:Exception Handling In C Plus Plus
Question 9 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
How do you catch all exceptions in C++?
Correct Answer: Option A — catch (...)
Detailed Academic Explanation:
catch (...) is the correct answer to “How do you catch all exceptions in C++”. This question is standard in competitive examination syllabi for Exception Handling In C Plus Plus.
💡Key Conceptual Anchor:Exception Handling In C Plus Plus
Question 10 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which function is used to retrieve the description of the exception in C++?
Correct Answer: Option B — what()
Detailed Academic Explanation:
what() is the correct answer to “Which function is used to retrieve the description of the exception in C++”. This question is standard in competitive examination syllabi for Exception Handling In C Plus Plus.
💡Key Conceptual Anchor:Exception Handling In C Plus Plus
Question 11 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What happens if an exception is thrown but not caught in C++?
Correct Answer: Option A — The program terminates abruptly
Detailed Academic Explanation:
The program terminates abruptly is the correct answer to “What happens if an exception is thrown but not caught in C++”. This question is standard in competitive examination syllabi for Exception Handling In C Plus Plus.
💡Key Conceptual Anchor:Exception Handling In C Plus Plus
Question 12 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of the following statements is true about the 'finally' block in C++ exception handling?
Correct Answer: Option C — It is executed regardless of whether an exception is thrown or not
Detailed Academic Explanation:
It is executed regardless of whether an exception is thrown or not is the correct answer to “Which of the following statements is true about the 'finally' block in C++ exception handling”. This question is standard in competitive examination syllabi for Exception Handling In C Plus Plus.
💡Key Conceptual Anchor:Exception Handling In C Plus Plus
Question 13 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the purpose of re-throwing an exception in C++?
Correct Answer: Option A — To handle the exception at a different location
Detailed Academic Explanation:
To handle the exception at a different location is the correct answer to “What is the purpose of re-throwing an exception in C++”. This question is standard in competitive examination syllabi for Exception Handling In C Plus Plus.
💡Key Conceptual Anchor:Exception Handling In C Plus Plus
Question 14 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which header file is necessary for exception handling in C++?
Correct Answer: Option A — <exception>
Detailed Academic Explanation:
<exception> is the correct answer to “Which header file is necessary for exception handling in C++”. This question is standard in competitive examination syllabi for Exception Handling In C Plus Plus.
💡Key Conceptual Anchor:Exception Handling In C Plus Plus
Question 15 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the function of the 'assert' macro in C++?
Correct Answer: Option A — It throws an exception if a condition is false
Detailed Academic Explanation:
It throws an exception if a condition is false is the correct answer to “What is the function of the 'assert' macro in C++”. This question is standard in competitive examination syllabi for Exception Handling In C Plus Plus.
💡Key Conceptual Anchor:Exception Handling In C Plus Plus
Question 16 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
How do you define your own exception class in C++?
Correct Answer: Option A — class MyException : public std::exception
Detailed Academic Explanation:
class MyException : public std::exception is the correct answer to “How do you define your own exception class in C++”. This question is standard in competitive examination syllabi for Exception Handling In C Plus Plus.
💡Key Conceptual Anchor:Exception Handling In C Plus Plus
Question 17 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the default behavior of an uncaught exception in C++?
Correct Answer: Option B — It causes the program to crash
Detailed Academic Explanation:
It causes the program to crash is the correct answer to “What is the default behavior of an uncaught exception in C++”. This question is standard in competitive examination syllabi for Exception Handling In C Plus Plus.
💡Key Conceptual Anchor:Exception Handling In C Plus Plus
Question 18 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the purpose of the 'std::runtime_error' class in C++ exception handling?
Correct Answer: Option A — It represents errors detected during runtime
Detailed Academic Explanation:
It represents errors detected during runtime is the correct answer to “What is the purpose of the 'std::runtime_error' class in C++ exception handling”. This question is standard in competitive examination syllabi for Exception Handling In C Plus Plus.
💡Key Conceptual Anchor:Exception Handling In C Plus Plus
Question 19 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of the following is true about the 'noexcept' specifier in C++?
Correct Answer: Option B — It indicates that a function will never throw an exception
Detailed Academic Explanation:
It indicates that a function will never throw an exception is the correct answer to “Which of the following is true about the 'noexcept' specifier in C++”. This question is standard in competitive examination syllabi for Exception Handling In C Plus Plus.
💡Key Conceptual Anchor:Exception Handling In C Plus Plus
Question 20 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the purpose of the 'std::bad_alloc' class in C++ exception handling?
Correct Answer: Option A — It represents errors related to dynamic memory allocation
Detailed Academic Explanation:
It represents errors related to dynamic memory allocation is the correct answer to “What is the purpose of the 'std::bad_alloc' class in C++ exception handling”. This question is standard in competitive examination syllabi for Exception Handling In C Plus Plus.
💡Key Conceptual Anchor:Exception Handling In C Plus Plus
Question 21 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What happens if an exception is thrown inside a 'catch' block in C++?
Correct Answer: Option C — The program terminates unexpectedly
Detailed Academic Explanation:
The program terminates unexpectedly is the correct answer to “What happens if an exception is thrown inside a 'catch' block in C++”. This question is standard in competitive examination syllabi for Exception Handling In C Plus Plus.
💡Key Conceptual Anchor:Exception Handling In C Plus Plus
Question 22 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
How do you re-throw the current exception in C++?
Correct Answer: Option A — throw
Detailed Academic Explanation:
throw is the correct answer to “How do you re-throw the current exception in C++”. This question is standard in competitive examination syllabi for Exception Handling In C Plus Plus.
💡Key Conceptual Anchor:Exception Handling In C Plus Plus
Question 23 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of the following statements about exception handling in C++ is correct?
Correct Answer: Option A — It is an alternative to error codes
Detailed Academic Explanation:
It is an alternative to error codes is the correct answer to “Which of the following statements about exception handling in C++ is correct”. This question is standard in competitive examination syllabi for Exception Handling In C Plus Plus.
💡Key Conceptual Anchor:Exception Handling In C Plus Plus
Question 24 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the purpose of the 'std::exception_ptr' class in C++ exception handling?
Correct Answer: Option A — It represents a pointer to an exception object
Detailed Academic Explanation:
It represents a pointer to an exception object is the correct answer to “What is the purpose of the 'std::exception_ptr' class in C++ exception handling”. This question is standard in competitive examination syllabi for Exception Handling In C Plus Plus.
💡Key Conceptual Anchor:Exception Handling In C Plus Plus
Question 25 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
How do you catch multiple exceptions of different types in C++?
Correct Answer: Option B — Using a single catch block with multiple exception types
Detailed Academic Explanation:
Using a single catch block with multiple exception types is the correct answer to “How do you catch multiple exceptions of different types in C++”. This question is standard in competitive examination syllabi for Exception Handling In C Plus Plus.
💡Key Conceptual Anchor:Exception Handling In C Plus Plus
Question 26 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which keyword is used to define a custom exception class in C++?
Correct Answer: Option D — class
Detailed Academic Explanation:
class is the correct answer to “Which keyword is used to define a custom exception class in C++”. This question is standard in competitive examination syllabi for Exception Handling In C Plus Plus.
💡Key Conceptual Anchor:Exception Handling In C Plus Plus
Question 27 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the purpose of the 'std::terminate' function in C++?
Correct Answer: Option D — It is called when an uncaught exception causes program termination
Detailed Academic Explanation:
It is called when an uncaught exception causes program termination is the correct answer to “What is the purpose of the 'std::terminate' function in C++”. This question is standard in competitive examination syllabi for Exception Handling In C Plus Plus.
💡Key Conceptual Anchor:Exception Handling In C Plus Plus
Question 28 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the purpose of the 'nothrow' parameter in the 'new' operator in C++?
Correct Answer: Option A — It prevents the 'new' operator from throwing exceptions
Detailed Academic Explanation:
It prevents the 'new' operator from throwing exceptions is the correct answer to “What is the purpose of the 'nothrow' parameter in the 'new' operator in C++”. This question is standard in competitive examination syllabi for Exception Handling In C Plus Plus.
💡Key Conceptual Anchor:Exception Handling In C Plus Plus
Question 29 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
How do you handle exceptions thrown from constructor initialization lists in C++?
Correct Answer: Option B — Using try-catch blocks outside the constructor
Detailed Academic Explanation:
Using try-catch blocks outside the constructor is the correct answer to “How do you handle exceptions thrown from constructor initialization lists in C++”. This question is standard in competitive examination syllabi for Exception Handling In C Plus Plus.
💡Key Conceptual Anchor:Exception Handling In C Plus Plus
Question 30 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the purpose of the 'std::bad_function_call' class in C++ exception handling?
Correct Answer: Option A — It represents errors in function calls
Detailed Academic Explanation:
It represents errors in function calls is the correct answer to “What is the purpose of the 'std::bad_function_call' class in C++ exception handling”. This question is standard in competitive examination syllabi for Exception Handling In C Plus Plus.
💡Key Conceptual Anchor:Exception Handling In C Plus Plus
Question 31 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which statement about the 'finally' block in C++ exception handling is true?
Correct Answer: Option C — It is executed regardless of whether an exception is thrown or not
Detailed Academic Explanation:
It is executed regardless of whether an exception is thrown or not is the correct answer to “Which statement about the 'finally' block in C++ exception handling is true”. This question is standard in competitive examination syllabi for Exception Handling In C Plus Plus.
💡Key Conceptual Anchor:Exception Handling In C Plus Plus
Question 32 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the purpose of the 'std::nested_exception' class in C++ exception handling?
Correct Answer: Option A — It represents exceptions nested within other exceptions
Detailed Academic Explanation:
It represents exceptions nested within other exceptions is the correct answer to “What is the purpose of the 'std::nested_exception' class in C++ exception handling”. This question is standard in competitive examination syllabi for Exception Handling In C Plus Plus.
💡Key Conceptual Anchor:Exception Handling In C Plus Plus
Question 33 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
How do you catch an exception by reference in C++?
Correct Answer: Option A — Using a catch block with an ampersand (&) after the exception type
Detailed Academic Explanation:
Using a catch block with an ampersand (&) after the exception type is the correct answer to “How do you catch an exception by reference in C++”. This question is standard in competitive examination syllabi for Exception Handling In C Plus Plus.
💡Key Conceptual Anchor:Exception Handling In C Plus Plus
Question 34 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the purpose of the 'std::logic_error' class in C++ exception handling?
Correct Answer: Option A — It represents errors in logical operations
Detailed Academic Explanation:
It represents errors in logical operations is the correct answer to “What is the purpose of the 'std::logic_error' class in C++ exception handling”. This question is standard in competitive examination syllabi for Exception Handling In C Plus Plus.
💡Key Conceptual Anchor:Exception Handling In C Plus Plus
Question 35 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What happens if an exception is thrown inside a destructor in C++?
Correct Answer: Option A — It leads to undefined behavior
Detailed Academic Explanation:
It leads to undefined behavior is the correct answer to “What happens if an exception is thrown inside a destructor in C++”. This question is standard in competitive examination syllabi for Exception Handling In C Plus Plus.
💡Key Conceptual Anchor:Exception Handling In C Plus Plus
Question 36 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which keyword is used to specify that a function will not throw any exceptions in C++?
Correct Answer: Option B — noexcept
Detailed Academic Explanation:
noexcept is the correct answer to “Which keyword is used to specify that a function will not throw any exceptions in C++”. This question is standard in competitive examination syllabi for Exception Handling In C Plus Plus.
💡Key Conceptual Anchor:Exception Handling In C Plus Plus
Question 37 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the purpose of the 'std::uncaught_exception' function in C++?
Correct Answer: Option A — It checks if there are any uncaught exceptions
Detailed Academic Explanation:
It checks if there are any uncaught exceptions is the correct answer to “What is the purpose of the 'std::uncaught_exception' function in C++”. This question is standard in competitive examination syllabi for Exception Handling In C Plus Plus.
💡Key Conceptual Anchor:Exception Handling In C Plus Plus
Question 38 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which standard header file is required for exception handling in C++?
Correct Answer: Option A — <stdexcept>
Detailed Academic Explanation:
<stdexcept> is the correct answer to “Which standard header file is required for exception handling in C++”. This question is standard in competitive examination syllabi for Exception Handling In C Plus Plus.
💡Key Conceptual Anchor:Exception Handling In C Plus Plus
Question 39 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
How do you specify that a function will throw no exceptions in C++?
Correct Answer: Option A — Using the 'noexcept' specifier
Detailed Academic Explanation:
Using the 'noexcept' specifier is the correct answer to “How do you specify that a function will throw no exceptions in C++”. This question is standard in competitive examination syllabi for Exception Handling In C Plus Plus.
💡Key Conceptual Anchor:Exception Handling In C Plus Plus
Question 40 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the purpose of the 'std::exception_ptr::rethrow' function in C++?
Correct Answer: Option A — It rethrows the current exception
Detailed Academic Explanation:
It rethrows the current exception is the correct answer to “What is the purpose of the 'std::exception_ptr::rethrow' function in C++”. This question is standard in competitive examination syllabi for Exception Handling In C Plus Plus.
💡Key Conceptual Anchor:Exception Handling In C Plus Plus
✓Link copied to clipboard
Continue Your Practice
Advance Html — Part 1
Master the next curriculum module with 40 exam-standard MCQs.
💡Examiner's Advisory for Programming & Software Development
In competitive commission exams (FPSC, PPSC, KPPSC, SPSC, CSS, PMS), questions are frequently phrased with distractor options designed to catch rote learners. Whenever you answer an MCQ, read the Detailed Academic Explanation and Conceptual Anchor to understand why the remaining options are incorrect.