Skip to content
main-logo
  • +91 637-050-2482
  • santuitreturns@gmail.com
Menu
Menu
  • Home
  • Income Tax
    • Income From Salary
    • Profit or gain from Business/Profession.
    • Capital Gain
    • Income From Other Sources
    • 80C to 80U
    • TDS & TCS
    • ITR FORMS
  • International Taxation
    • Transfer Pricing
    • Non-Resident Taxation
    • Foreign Tax Credit (FTC)
    • Model Tax Convention
    • Base Erosion and Profit Shifting (BEPS)
  • GST
  • Accounting
  • MCQs
    • NEET
    • NEET QUIZ TEST
    • NEET PG MCQ’s
    • NEET PG QUIZ TEST
    • Civil Engineering
    • Mechanical Engineering MCQs
    • CHSL EXAM
      • Logical Reasoning
  • Others
    • Job Tips
  • CA Courses
    • CA Inter/IPCC

10+ TOP C++ MCQs on Constructors and Destructors – 1

Posted on September 24, 2023

1. What is the difference between constructors and destructors?

A. They have a different function name
B. Constructors does not have return type whereas destructors do have
C. Constructors allow function parameters whereas destructors do not
D. Constructors does not function parameters

View Answer

Answer: C

Explanation: 

 Both the constructors and destructors have the same function name and both of them do not have return type but constructors allow function parameters whereas destructors do not.

2. How many Destructors are allowed in a Class?

A. 1
B. 2
C. 3
D. Any number

View Answer

Answer: A

Explanation:

 A class in C++ allows only one destructor, which is called whenever the lifetime of an object ends.

3. What will be the output of the following C++ code?
#include 
#include 
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{
	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;
}

A.

A’s Constructor called
B’s Constructor called
B.


A’s Destructor called
B’s Destructor called

C.

A’s Constructor called
B’s Constructor called
B’s Destructor called
A’s Destructor called

D.

A’s Constructor called
B’s Constructor called
A’s Destructor called
B’s Destructor called

View Answer

Answer: C

Explanation:

 The destructors for an object is called before the destructor of its data members or bases.

4. What will be the output of the following C++ code?
#include 
#include 
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{
public:
	B(){
		cout<<"B's Constructor called\n";
	}
	~B(){
		cout<<"B's Destructor called\n";
	}
};
int main(int argc, char const *argv[])
{
	B b1;
}


A.

A’s Constructor called
B’s Constructor called

B.

A’s Destructor called
B’s Destructor called

C.

A’s Constructor called
B’s Constructor called
B’s Destructor called
A’s Destructor called

D.

A’s Constructor called
B’s Constructor called
A’s Destructor called
B’s Destructor called

View Answer

Answer: C

Explanation:

Though B class have no data member of the class but as class B is derived from class A, the destructor of class A will be called to destroy the data inherited from class A to class B.

5. What will be the output of the following C++ code?
#include 
#include 
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;
}

A.

A’s Constructor called
B’s Constructor called

B.

A’s Destructor called
B’s Destructor called

C.

A’s Constructor called
A’s Constructor called
B’s Constructor called
B’s Destructor called
A’s Destructor called
A’s Destructor called

D.

A’s Constructor called
B’s Constructor called
A’s Destructor called
B’s Destructor called

View Answer

Answer: C

Explanation:

 There are two calls to constructor of class A, one is for the data member of class B and second because class B is derived from class A. Similarly two destructor calls.

6. What will be the output of the following C++ code?
#include 
#include 
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{
	static 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;
}

A.

A’s Constructor called
B’s Constructor called

B.

B’s Constructor called
B’s Destructor called

C.

A’s Constructor called
B’s Constructor called
B’s Destructor called
A’s Destructor called

D.

A’s Constructor called
B’s Constructor called
A’s Destructor called
B’s Destructor called

View Answer

Answer: B

Explanation:

 Here as ‘a’ is a static member of class B and as all static members should be initialized separately as no object creation initializes static member and as ‘a’ is not initialized, hence no call will be made to the constructor of class A.

7. What will be the output of the following C++ code?
#include 
#include 
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{
	static A a;
public:
	B(){
		cout<<"B's Constructor called\n";
	}
	~B(){
		cout<<"B's Destructor called\n";
	}
};
 
A B::a;
 
int main(int argc, char const *argv[])
{
	return 0;
}

A.

A’s Constructor called
A’s Destructor called

B.

B’s Constructor called
B’s Destructor called

C.

A’s Constructor called
B’s Constructor called
B’s Destructor called
A’s Destructor called

D.

A’s Constructor called
B’s Constructor called
A’s Destructor called
B’s Destructor called

View Answer

Answer: A

Explanation:

 Here as no object of B is declared so no call to B’s constructor but as we have initialised the static member ‘a’ of class B, hence A’s constructor and destructor will be called once.

8. 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;
		}
       }

A. A a(5);
B. A a;
C. A a = A(5);
D. A a = A();

View Answer

Answer: C

Explanation:

 Explicit call represents the programmer by himself mentioning the type name. So A a = A(5); is the correct explicit call as we are mentioning typename A(5) from our side, whereas A a = A(); is not the correct call because no such constructor is there in class A.

    You May Also Like...

  • 10+ TOP MCQs on C++ vs C
  • 10+ TOP MCQs on C++ Concepts
  • 10+ TOP MCQs on C++ Concepts -2
  • 10+ TOP C++ MCQs on Void
  • 10+ TOP C++ MCQs on Declaration
  • 10+ TOP C++ MCQs on Pointer to Void
  • 10+ TOP C++ MCQs on Pointer to Structures
  • 10+ TOP C++ MCQs on Character Classification

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Quick Links

  • Home
  • About Us
  • Privacy Policy
  • Terms of Use
  • Disclaimer
  • Contact Us

Categories

  • Income Tax
  • International Taxation
  • GST
  • MCQs
  • Others
  • CA Courses

Latest Posts

  • Five changes in ITR forms of FY 2024-25 (AY 2025-26)
  • Form 10-IEA: Option to Choose Old Tax Regime
  • What is Section 54EC of the Income Tax Act?
  • What is Section 54F of the Income Tax Act?
©2025 Online Solves. All rights Reserved | Developed by AlgoPage IT Solutions Pvt. Ltd.
We use cookies on our website to give you the most relevant experience by remembering your preferences and repeat visits. By clicking “Accept All”, you consent to the use of ALL the cookies. However, you may visit "Cookie Settings" to provide a controlled consent.
Cookie SettingsAccept All
Manage consent

Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. These cookies ensure basic functionalities and security features of the website, anonymously.
CookieDurationDescription
cookielawinfo-checkbox-analytics11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Analytics".
cookielawinfo-checkbox-functional11 monthsThe cookie is set by GDPR cookie consent to record the user consent for the cookies in the category "Functional".
cookielawinfo-checkbox-necessary11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookies is used to store the user consent for the cookies in the category "Necessary".
cookielawinfo-checkbox-others11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Other.
cookielawinfo-checkbox-performance11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Performance".
viewed_cookie_policy11 monthsThe cookie is set by the GDPR Cookie Consent plugin and is used to store whether or not user has consented to the use of cookies. It does not store any personal data.
Functional
Functional cookies help to perform certain functionalities like sharing the content of the website on social media platforms, collect feedbacks, and other third-party features.
Performance
Performance cookies are used to understand and analyze the key performance indexes of the website which helps in delivering a better user experience for the visitors.
Analytics
Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics the number of visitors, bounce rate, traffic source, etc.
Advertisement
Advertisement cookies are used to provide visitors with relevant ads and marketing campaigns. These cookies track visitors across websites and collect information to provide customized ads.
Others
Other uncategorized cookies are those that are being analyzed and have not been classified into a category as yet.
SAVE & ACCEPT