Skip to main content

Constructors And Destructors In C Plus Plus — Part 2 MCQs with Explanations

Practice high-yield Programming & Software Development MCQs on Constructors And Destructors In C Plus Plus — Part 2 with worked academic solutions for FPSC, PPSC, NTS, NITB, PTS.

Questions
28
Difficulty Level
Exam-Level
Target Exams
FPSC, PPSC, NTS...
Estimated Time
34 mins
Exam-Level FPSC PPSC NTS NITB PTS
Verified for Commission Syllabus • Oct 14, 2026
28

Verified Practice Questions

Interactive test mode with detailed academic worked solutions

Live Progress | 0/28 answered
✓ 0 correct ✗ 0 wrong 0% score
Question 1 of 28
★ FPSC ★ PPSC

What will be the output of the following C++ code? #include <iostream> #include <string> using namespace std; class A{ int a; public: A(int i){ a = i; } void assign(int i){ a = i; } int return_value(){ return a; } }; int main(int argc, char const *argv[]) { A obj; obj.assign(5); cout<<obj.return_value(); }

Question 2 of 28
★ FPSC ★ PPSC

How many types of constructors are there in C++?

Question 3 of 28
★ FPSC ★ PPSC

What will be the output of the following C++ code? #include <iostream> using namespace std; class A{ A(){ cout<<"Constructor called"; } }; int main(int argc, char const *argv[]) { A a; return 0; }

Question 4 of 28
★ FPSC ★ PPSC

What will be the output of the following C++ code? #include <iostream> using namespace std; class A{ public: int a; A(){ cout<<"Constructor called"; } }; int main(int argc, char const *argv[]) { A *a1 = (A*)malloc(sizeof(A)); return 0; }

Question 5 of 28
★ FPSC ★ PPSC

Which of the following constructors are provided by the C++ compiler if not defined in a class?

Question 6 of 28
★ FPSC ★ PPSC

What will be the output of the following C++ code? #include <iostream> using namespace std; class A{ public: A(){ cout<<"Constructor called"; } }; int main(int argc, char const *argv[]) { A *a; return 0; }

Question 7 of 28
★ FPSC ★ PPSC

What will be the output of the following C++ code? #include <iostream> using namespace std; class A{ public: int a; A(int a=0){ this->a = a; } }; int main(int argc, char const *argv[]) { A a1, a2(10); cout<<a2.a; return 0; }

Question 8 of 28
★ FPSC ★ PPSC

What will be the output of the following C++ code? #include <iostream> using namespace std; class A{ public: int a; A(){ cout<<"Constructor called"; } } a; int main(int argc, char const *argv[]) { return 0; }

Question 9 of 28
★ FPSC ★ PPSC

What will be the output of the following C++ code? #include <iostream> using namespace std; class A{ public: int a; A(int a){ this->a = a; } }; int main(int argc, char const *argv[]) { A a1, a2(10); cout<<a2.a; return 0; }

Question 10 of 28
★ FPSC ★ PPSC

What will be the output of the following C++ code? #include <iostream> #include <string> using namespace std; class A{ mutable int a; public: A(){ cout<<"A's default constructor called\n"; } A(const A& a){ cout<<"A's copy Constructor called\n"; } }; class B{ A obj; public: B(){ cout<<"B's Constructor called\n"; } }; int main(int argc, char const *argv[]) { B b1; B b2; }

Question 11 of 28
★ FPSC ★ PPSC

Why constructors are efficient instead of a function init() defined by the user to initialize the data members of an object?

Question 12 of 28
★ FPSC ★ PPSC

What will be the output of the following C++ code? #include <iostream> using namespace std; class A{ A(){ cout<<"A's Constructor called\n"; } }; class B { public: A a; B(){ cout<<"B's constructor called\ns"; } }; int main(int argc, char const *argv[]) { B b; return 0; }

Question 13 of 28
★ FPSC ★ PPSC

What is a copy constructor?

Question 14 of 28
★ FPSC ★ PPSC

When a copy constructor is called?

Question 15 of 28
★ FPSC ★ PPSC

Which of the following represents the correct explicit call to a constructor of class A? class A{ int a; public: A(int i) { a = i; } }

Question 16 of 28
★ FPSC ★ PPSC

What will be the output of the following C++ code? #include <iostream> using namespace std; class A{ ~A(){} }; class B { public: A a; }; int main(int argc, char const *argv[]) { B b; return 0; }

Question 17 of 28
★ FPSC ★ PPSC

How many parameters does a default constructor require?

Question 18 of 28
★ FPSC ★ PPSC

In the following C++ code how many times the string "A's constructor called" will be printed? #include <iostream> #include <string> using namespace std; class A{ int a; public: A(){ cout<<"A's constructor called"; } }; class B{ static A a; public: B(){ cout<<"B's constructor called"; } static A get(){ return a; } }; A B::a; int main(int argc, char const *argv[]) { B b; A a1 = b.get(); A a2 = b.get(); A a3 = b.get(); }

Question 19 of 28
★ FPSC ★ PPSC

What is the role of destructors in Classes?

Question 20 of 28
★ FPSC ★ PPSC

What is syntax of defining a destructor of class A?

Question 21 of 28
★ FPSC ★ PPSC

What happens if a user forgets to define a constructor inside a class?

Question 22 of 28
★ FPSC ★ PPSC

What will be the output of the following C++ code? #include <iostream> using namespace std; class A{ public: int a; }; int main(int argc, char const *argv[]) { A a1 = {10}; A a2 = a1; cout<<a1.a<<a2.a; return 0; }

Question 23 of 28
★ FPSC ★ PPSC

What will be the output of the following C++ code? #include <iostream> using namespace std; class A{ public: int a; A(){ cout<<"Constructor called\n"; } } a; int main(int argc, char const *argv[]) { cout<<"Main function\n"; return 0; }

Question 24 of 28
★ FPSC ★ PPSC

What will be the output of the following C++ code? #include <iostream> #include <string> using namespace std; class A{ int a; A(){ a = 5; } public: void assign(int i){ a = i; } int return_value(){ return a; } }; int main(int argc, char const *argv[]) { A obj; obj.assign(10); cout<<obj.return_value(); }

Question 25 of 28
★ FPSC ★ PPSC

What will be the output of the following C++ code? #include <iostream> #include <string> using namespace std; class A{ mutable int a; public: A(){ cout<<"A's Constructor called\n"; } ~A(){ cout<<"A's Destructor called\n"; } }; class B: public A{ A a; public: B(){ cout<<"B's Constructor called\n"; } ~B(){ cout<<"B's Destructor called\n"; } }; int main(int argc, char const *argv[]) { B b1; }

Question 26 of 28
★ FPSC ★ PPSC

What will be the output of the following C++ code? #include <iostream> using namespace std; class A{ A(){ cout<<"A's Constructor called\n"; } friend class B; }; class B { public: A a; B(){ cout<"B's constructor called\ns"; } }; int main(int argc, char const *argv[]) { B b; return 0; }

Question 27 of 28
★ FPSC ★ PPSC

What is the role of a constructor in classes?

Question 28 of 28
★ FPSC ★ PPSC

How many Destructors are allowed in a Class?

✓ 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 →