MCQ 2
MCQ 2
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
A) variable
B) object
C) function
D) name
A) define variables
B) allocate variables
C) initialize variables
D) initialize object
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.
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
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 …………………
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.
B) dynamic construction
C) initial construction
D) static construction
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
C) static initialization
D) variable initialization
A) class
B) object
C) function
D) variable
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
14. A) tilde
15. D) constructor
20. B) object