github

Made bySaurav Hathi

MCQ Test C/C++: Constructor and Destructor 1

Q1:

Constructors are used to

Tags:
Section:
Core Programming
Options:
Q2:

When a copy constructor may be called?

Tags:
Section:
Core Programming
Options:
Q3:

What is the output of following C++ program?

#include <iostream>

using namespace std;

class Point

{

 int x, y;

public:

Point(const Point &p) { x = p.x; y = p.y; }

int getX() { return x; }

int getY() { return y; }

};

int main()

{

Point p1;

Point p2 = p1;

cout << "x = " << p2.getX() << " y = " << p2.getY();

return 0;

}

Tags:
Section:
Core Programming
Options:
Q4:

C++ provides a special ………………… called the constructor, which enables an object to initialize itself when it is created.

Tags:
Section:
Core Programming
Options:
Q5:

A constructor has the same …………….. as that of class.

Tags:
Section:
Core Programming
Options:
Q6:

Constructors are normally used to …………….. and to allocate memory.

Tags:
Section:
Core Programming
Options:
Q7:

A constructor that accepts no parameters is called the …………….

Tags:
Section:
Core Programming
Options:
Q8:

Constructors cannot be inherited, through a derived class can call the ………………. constructor.

Tags:
Section:
Core Programming
Options:
Q9:

State whether the following statements about the constructor are True or False.
i) Constructors should always be declared in the private section.
ii) Constructors are invoked automatically when the objects are created.

Tags:
Section:
Core Programming
Options:
Q10:

The constructors that can take arguments are called ……………...

Tags:
Section:
Core Programming
Options:
Q11:

When an object is created and initialized at the same time, a ………………. gets called.

Tags:
Section:
Core Programming
Options:
Q12:

In C++, ……………………. creates objects even through it was not defined in the class.

Tags:
Section:
Core Programming
Options:
Q13:

…………….. constructor will not do anything and defined just to satisfy the compiler

Tags:
Section:
Core Programming
Options:
Q14:

The ………………… constructor can be called with either one argument or no arguments.

Tags:
Section:
Core Programming
Options:
Q15:

A ………………….. is used to declare and initialize an object from another object.

Tags:
Section:
Core Programming
Options: