Self-Assessment 2 Flashcards

1
Q

Which of the following is/are automatically added to every class, if we do not write our own?

A

C. Constructor without any parameter

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

include <iostream></iostream>

What will be the output of the following program?

using namespace std;

class Point {
Point () { cout &laquo_space;“Constructor Called”;}

int main()
{
Point t1;
return 0;
}

A

C. Constructor Called

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Which of the following gets called when an object is being created?

A

C. Constructor

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Can we define a class without creating constructors

A

A. True/Yes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

include <iostream></iostream>

What will be the output of the following program:

using namespace std;

class demo {
public:
int f_num, s_num;

sum(int a, int b) {
    cout << a + b;
} };

int main() {
demo d1;
d1.sum(d1.f_num = 10, d1.s_num = 20);
return 0;
}

A

C. 30

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Which constructor function is designed to copy object of same class type?

A

A. Copy Constructor

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Allocation of memory to objects at the time of their construction is known as _____ of objects

A

B. Dynamic Construction

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Which among the following best describes constructor overloading?

A

C. Defining more than one constructor in a single class with different signature

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

If new operator is used, then the constructor function is

A

C. Dynamic Constructor

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Does constructor overloading include different return types for constructors to be overloaded?

A

D. The constructors doesn’t have any return type.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Which among the following is a possible way to overload a constructor?

A

A. Define default constructor, 1 parameter constructor and 2 parameter constructor

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Which is executed automatically when the control reaches the end of the class scope?

A

B. Destructor

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

The special character related to destructor is

A

D. ~

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

A destructor is used to destroy the objects that have been created by a

A

C. Constructor

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

______ provides the flexibility of using different format of data at runtime depending upon the situation

A

A. Dynamic Initialization

How well did you know this?
1
Not at all
2
3
4
5
Perfectly