Skip to main content

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
Question 1 of 26
★ FPSC ★ PPSC

Which keyword is used to specify that a function will throw any exceptions in C++?

Question 2 of 26
★ FPSC ★ PPSC

What is the purpose of the 'std::unexpected' function in C++ exception handling?

Question 3 of 26
★ FPSC ★ PPSC

Which statement about exception handling in C++ is true?

Question 4 of 26
★ FPSC ★ PPSC

What is the behavior of the 'std::terminate' function in C++?

Question 5 of 26
★ FPSC ★ PPSC

Uncaught exception leads to . . . . . . . .

Question 6 of 26
★ 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; } }

Question 7 of 26
★ FPSC ★ PPSC

What is an error in C++?

Question 8 of 26
★ FPSC ★ PPSC

What are the different types of exceptions?

Question 9 of 26
★ FPSC ★ PPSC

Why do we need to handle exceptions?

Question 10 of 26
★ FPSC ★ PPSC

Which keyword is used to throw an exception?

Question 11 of 26
★ FPSC ★ PPSC

How Exception handling is implemented in the C++ program?

Question 12 of 26
★ FPSC ★ PPSC

Header file used for exception handling in C++?

Question 13 of 26
★ 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"; } }

Question 14 of 26
★ FPSC ★ PPSC

Where should we place catch block of the derived class in a try-catch block?

Question 15 of 26
★ 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"; } }

Question 16 of 26
★ FPSC ★ PPSC

An uncaught handler returns to . . . . . . . .

Question 17 of 26
★ FPSC ★ PPSC

What is an exception in C++ program?

Question 18 of 26
★ FPSC ★ PPSC

Which part of the try-catch block is always fully executed?

Question 19 of 26
★ FPSC ★ PPSC

By default, what a program does when it detects an exception?

Question 20 of 26
★ FPSC ★ PPSC

What is Re-throwing an exception means in C++?

Question 21 of 26
★ 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; } }

Question 22 of 26
★ FPSC ★ PPSC

What id the syntax for catching any type of exceptions?

Question 23 of 26
★ FPSC ★ PPSC

Which of the following is an exception in C++?

Question 24 of 26
★ 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"; } }

Question 25 of 26
★ 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"; } }

Question 26 of 26
★ FPSC ★ PPSC

What is the difference between error and exception?

✓ Link copied to clipboard
Continue Your Practice

Advance Html — Part 1

Master the next curriculum module with 40 exam-standard MCQs.

Next Practice Set →

💡 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.

More Modules in Programming & Software Development

View All →
📚

Study Guides

Topic summaries and syllabus breakdown

Explore Guides →
🎯

Complete Library

Search through 78,000+ verified MCQs

Browse Library →
📱

Mobile App

Offline mock tests and instant bookmarks

Get Mobile App →