Top 20 MCQ On Constructors And Destructors In C++

This set of multiple choice questions on C++ constructors and destructors includes collection of top 20 MCQ questions about special characteristics of constructor, about different types of constructors; parameterized constructors, default constructor, copy constructor, implicit constructor and default argument constructor. It also includes about dynamic initialization of objects, dynamic constructors and destructors. 
 
1. C++ provides a special ..................... called the constructor, which enables an object to initialize itself when it is created.
A) friend function
B) member function
C) public function
D) private function

2.  A constructor has the same ................. as that of class.
A) variable
B) object
C) function
D) name

3. Constructors are normally used to ................. and to allocate memory.
A) define variables
B) allocate variables
C) initialize variables
D) initialize object

4. A constructor  that accepts no parameters is called the ................
A) default constructor
B) parameterized constructor
C) implicit constructor
D) null constructor

5. Constructors cannot be inherited, through a derived class can call the ................... constructor.
A) base class
B) derived class
C) void class
D) default class

6. State whether the following statements about  the constructor are True or False.
i) constructors should be declared in the private section.
ii) constructors are invoked automatically when the objects are created.
A) True, True
B) True, False
C) False, True
D) False, False

7. The constructors that can take arguments are called ............... constructors.
A) default constructor
B) parameterized constructor
C) implicit constructor
D) argument constructor

8. When an object is created and initialized at the same time, a ................... gets called.
A) default constructor
B) parameterized constructor
C) implicit constructor
D) copy constructor

9. In C++, ......................... creates objects, even through it was not defined in the class.
A) default constructor
B) parameterized constructor
C) implicit constructor
D) copy constructor

10. ................. constructor will not do anything and defined just to satisfy the compiler
A) default
B) parameterized
C) implicit
D) copy


11. The ..................... constructor can be called with either one argument or no arguments.
A) default
B) default argument 
C) implicit
D) copy

12. A ....................... is used to declare and initialize an object from another object.
A) default constructor
B) default argument constructor
C) implicit constructor
D) copy constructor

13. A ................ takes a reference to an object of the same class as itself as an argument.
A) default constructor
B) default argument constructor
C) implicit constructor
D) copy constructor

14. Destructor is a member function whose name is same as the class name but is preceded by a ...........
A) tilde
B) hash
C) dot
D) dollor

15. A destructor is used to destroy the objects that have been created by a ....................
A) object
B) class
C) function
D) constructor

16. Whenever const objects try to invoke non-const member functions, the compiler .....................
A) return zero value
B) return null
C) generate error
D) return no value

17. Allocation of memory to objects at the time of their construction is known as ................ of objects.
A) run time construction
B) dynamic construction
C) initial construction
D) static construction

18. The process of initializing through a copy constructor is known as ...............
A) copy process
B) copy registration
C) copy initialization
D) initialization process

19. .................... provides the flexibility of using different format of data at runtime depending upon the situation.
A) dynamic initialization
B) run time initialization
C) static initialization
D) variable initialization

20.  An ....................... with a constructor or destructor cannot be used as a member or a union.
A) class
B) object
C) function
D) variable

Answers

1. B) member function
2. D) name
3. C) initialize variables
4. A) default constructor
5. A) base class
6. C) False, True
7. B) parameterized constructor
8. D) copy constructor
9. C) implicit constructor
10. C) implicit
11. B) default argument
12. D) copy constructor
13. D) copy constructor
14. A) tilde
15. D) constructor
16. C) generate error
17. B) dynamic construction
18. C) copy initialization
19. A) dynamic initialization
20. B) object

Read Next:Multiple Choice Questions On C++ Operator Overloading

Read More: C and C++ MCQ Questions

Top 20 MCQ On Constructors And Destructors In C++
2017-05-07T01:17:00-07:00
Shuseel Baral
C & CPP|Multiple Choice Question (MCQ)|