Exception Handling In C Plus Plus — Part 2 MCQs with Explanations
Practice high-yield Programming & Software Development MCQs on Exception Handling In C Plus Plus — Part 2 with worked academic solutions for FPSC, PPSC, NTS, NITB, PTS.
Questions
26
Difficulty Level
Exam-Level
Target Exams
FPSC, PPSC, NTS...
Estimated Time
32 mins
Exam-Level FPSC PPSC NTS NITB PTS
Verified for Commission Syllabus • Oct 14, 2026
26
Verified Practice Questions
Interactive test mode with detailed academic worked solutions
Live Progress|0/26 answered
✓0 correct
✗0 wrong
0% score
🎉 Set complete! All 26 questions answered.
Question 1 of 26
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which keyword is used to specify that a function will throw any exceptions in C++?
Correct Answer: Option D — throws
Detailed Academic Explanation:
throws is the correct answer to “Which keyword is used to specify that a function will 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 2 of 26
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the purpose of the 'std::unexpected' function in C++ exception handling?
Correct Answer: Option A — It is called when an unexpected exception occurs
Detailed Academic Explanation:
It is called when an unexpected exception occurs is the correct answer to “What is the purpose of the 'std::unexpected' function 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 3 of 26
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which statement about exception handling in C++ is true?
Correct Answer: Option A — An exception thrown inside a 'try' block must always be caught
Detailed Academic Explanation:
An exception thrown inside a 'try' block must always be caught is the correct answer to “Which statement about exception handling in C++ 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 4 of 26
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the behavior of the 'std::terminate' function in C++?
Correct Answer: Option B — It terminates the program
Detailed Academic Explanation:
It terminates the program is the correct answer to “What is the behavior 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 5 of 26
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Uncaught exception leads to . . . . . . . .
Correct Answer: Option A — termination of program
Detailed Academic Explanation:
termination of program is the correct answer to “Uncaught exception leads to . . . . . . . .”. 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 26
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following C++ code? #include <iostream> #include <string> #include <cstdlib> using namespace std; void func(int a, int b) { if(b == 0){ throw "This value of b will make the product zero. " "So please provide positive values.\n"; } else{ cout<<"Product of "<<a<<" and "<<b<<" is: "<<a*b<<endl; } } int main() { try{ func(5,0); } catch(const char* e){ cout<<e; } }
Correct Answer: Option C — This value of b will make the product zero. So please provide positive values.
Detailed Academic Explanation:
This value of b will make the product zero. So please provide positive values. is the correct answer to “What will be the output of the following C++ code? #include <iostream> #include <string> #include <cstdlib> using namespace std; void func(int a, int b) { if(b == 0){ throw "This value of b will make the product zero. " "So please provide positive values.\n"; } else{ cout<<"Product of "<<a<<" and "<<b<<" is: "<<a*b<<endl; } } int main() { try{ func(5,0); } catch(const char* e){ cout<<e; } }”. 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 26
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is an error in C++?
Correct Answer: Option A — Violation of syntactic and semantic rules of a languages
Detailed Academic Explanation:
Violation of syntactic and semantic rules of a languages is the correct answer to “What is an error 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 26
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What are the different types of exceptions?
Correct Answer: Option B — 2
Detailed Academic Explanation:
2 is the correct answer to “What are the different types of exceptions”. 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 26
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Why do we need to handle exceptions?
Correct Answer: Option A — To avoid unexpected behaviour of a program during run-time
Detailed Academic Explanation:
To avoid unexpected behaviour of a program during run-time is the correct answer to “Why do we need to handle exceptions”. 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 26
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which keyword is used to throw an exception?
Correct Answer: Option B — throw
Detailed Academic Explanation:
throw is the correct answer to “Which keyword is used to throw an exception”. 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 26
★ FPSC
★ PPSC
★ FPSC
★ PPSC
How Exception handling is implemented in the C++ program?
Correct Answer: Option B — Using try-catch block
Detailed Academic Explanation:
Using try-catch block is the correct answer to “How Exception handling is implemented in the C++ program”. 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 26
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Header file used for exception handling in C++?
Correct Answer: Option D — <exception>
Detailed Academic Explanation:
<exception> is the correct answer to “Header file used 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 13 of 26
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following C++ code? #include <iostream> #include <string> #include <cstdlib> using namespace std; class A { int a; public: A(){} }; class B: public A { int b; public: B(){} }; void func() { B b; throw b; } int main() { try{ func(); } catch(B b){ cout<<"Caught B Class\n"; } catch(A a){ cout<<"Caught A Class\n"; } }
Correct Answer: Option A — Caught B Class
Detailed Academic Explanation:
Caught B Class is the correct answer to “What will be the output of the following C++ code? #include <iostream> #include <string> #include <cstdlib> using namespace std; class A { int a; public: A(){} }; class B: public A { int b; public: B(){} }; void func() { B b; throw b; } int main() { try{ func(); } catch(B b){ cout<<"Caught B Class\n"; } catch(A a){ cout<<"Caught A Class\n"; } }”. 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 26
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Where should we place catch block of the derived class in a try-catch block?
Correct Answer: Option A — Before the catch block of Base class
Detailed Academic Explanation:
Before the catch block of Base class is the correct answer to “Where should we place catch block of the derived class in a try-catch block”. 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 26
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following C++ code? #include <iostream> #include <string> #include <cstdlib> using namespace std; class A { int a; public: A(){} }; class B: public A { int b; public: B(){} }; void func1() { B b; throw b; } void func2() { A a; throw a; } int main() { try{ func1(); } catch(...){ cout<<"Caught All types of exceptions\n"; } try{ func2(); } catch(B b){ cout<<"Caught All types of exceptions\n"; } }
Correct Answer: Option B — Caught All types of exceptions Aborted (core dumped)
Detailed Academic Explanation:
Caught All types of exceptions Aborted (core dumped) is the correct answer to “What will be the output of the following C++ code? #include <iostream> #include <string> #include <cstdlib> using namespace std; class A { int a; public: A(){} }; class B: public A { int b; public: B(){} }; void func1() { B b; throw b; } void func2() { A a; throw a; } int main() { try{ func1(); } catch(...){ cout<<"Caught All types of exceptions\n"; } try{ func2(); } catch(B b){ cout<<"Caught All types of exceptions\n"; } }”. 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 26
★ FPSC
★ PPSC
★ FPSC
★ PPSC
An uncaught handler returns to . . . . . . . .
Correct Answer: Option C — its callee
Detailed Academic Explanation:
its callee is the correct answer to “An uncaught handler returns to . . . . . . . .”. 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 26
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is an exception in C++ program?
Correct Answer: Option A — A problem that arises during the execution of a program
Detailed Academic Explanation:
A problem that arises during the execution of a program is the correct answer to “What is an exception in C++ program”. 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 26
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which part of the try-catch block is always fully executed?
Correct Answer: Option C — finally part
Detailed Academic Explanation:
finally part is the correct answer to “Which part of the try-catch block is always fully executed”. 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 26
★ FPSC
★ PPSC
★ FPSC
★ PPSC
By default, what a program does when it detects an exception?
Correct Answer: Option B — Results in the termination of the program
Detailed Academic Explanation:
Results in the termination of the program is the correct answer to “By default, what a program does when it detects an exception”. 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 26
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is Re-throwing an exception means in C++?
Correct Answer: Option D — All of the mentioned
Detailed Academic Explanation:
All of the mentioned is the correct answer to “What is Re-throwing an exception means 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 21 of 26
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following C++ code? #include <iostream> #include <string> #include <cstdlib> using namespace std; void func(int a, int b) { if(b < 1){ throw b; } else{ cout<<"Product of "<<a<<" and "<<b<<" is: "<<a*b<<endl; } } int main() { try { try { func(5,-1); } catch(int b) { if(b==0) throw "value of b is zero\n"; else throw "value of b is less than zero\n"; } } catch(const char* e) { cout<<e; } }
Correct Answer: Option B — value of b is less than zero
Detailed Academic Explanation:
value of b is less than zero is the correct answer to “What will be the output of the following C++ code? #include <iostream> #include <string> #include <cstdlib> using namespace std; void func(int a, int b) { if(b < 1){ throw b; } else{ cout<<"Product of "<<a<<" and "<<b<<" is: "<<a*b<<endl; } } int main() { try { try { func(5,-1); } catch(int b) { if(b==0) throw "value of b is zero\n"; else throw "value of b is less than zero\n"; } } catch(const char* e) { cout<<e; } }”. 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 26
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What id the syntax for catching any type of exceptions?
Correct Answer: Option B — catch(...)
Detailed Academic Explanation:
catch(...) is the correct answer to “What id the syntax for catching any type of exceptions”. 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 26
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of the following is an exception in C++?
Correct Answer: Option A — Divide by zero
Detailed Academic Explanation:
Divide by zero is the correct answer to “Which of the following is 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 24 of 26
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following C++ code? #include <iostream> #include <string> #include <cstdlib> using namespace std; class A { int a; public: A(){} }; class B: public A { int b; public: B(){} }; void func() { B b; throw b; } int main() { try{ func(); } catch(A a){ cout<<"Caught A Class\n"; } catch(B b){ cout<<"Caught B Class\n"; } }
Correct Answer: Option B — Caught A Class
Detailed Academic Explanation:
Caught A Class is the correct answer to “What will be the output of the following C++ code? #include <iostream> #include <string> #include <cstdlib> using namespace std; class A { int a; public: A(){} }; class B: public A { int b; public: B(){} }; void func() { B b; throw b; } int main() { try{ func(); } catch(A a){ cout<<"Caught A Class\n"; } catch(B b){ cout<<"Caught B Class\n"; } }”. 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 26
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What happens when this C++ program is compiled? #include <iostream> #include <string> #include <cstdlib> using namespace std; class A { int a; public: A(){} }; class B: public A { int b; public: B(){} }; void func() { B b; throw b; } int main() { try{ func(); } catch(A a){ cout<<"Caught A Class\n"; } catch(B b){ cout<<"Caught B Class\n"; } }
Correct Answer: Option C — The program compiles successfully with warnings
Detailed Academic Explanation:
The program compiles successfully with warnings is the correct answer to “What happens when this C++ program is compiled? #include <iostream> #include <string> #include <cstdlib> using namespace std; class A { int a; public: A(){} }; class B: public A { int b; public: B(){} }; void func() { B b; throw b; } int main() { try{ func(); } catch(A a){ cout<<"Caught A Class\n"; } catch(B b){ cout<<"Caught B Class\n"; } }”. 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 26
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the difference between error and exception?
Correct Answer: Option C — Exceptions can be handled at the run-time but the errors cannot
Detailed Academic Explanation:
Exceptions can be handled at the run-time but the errors cannot is the correct answer to “What is the difference between error and exception”. 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.