Self-Assessment 2 Flashcards
Which of the following is/are automatically added to every class, if we do not write our own?
C. Constructor without any parameter
include <iostream></iostream>
What will be the output of the following program?
using namespace std;
class Point {
Point () { cout «_space;“Constructor Called”;}
int main()
{
Point t1;
return 0;
}
C. Constructor Called
Which of the following gets called when an object is being created?
C. Constructor
Can we define a class without creating constructors
A. True/Yes
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;
}
C. 30
Which constructor function is designed to copy object of same class type?
A. Copy Constructor
Allocation of memory to objects at the time of their construction is known as _____ of objects
B. Dynamic Construction
Which among the following best describes constructor overloading?
C. Defining more than one constructor in a single class with different signature
If new operator is used, then the constructor function is
C. Dynamic Constructor
Does constructor overloading include different return types for constructors to be overloaded?
D. The constructors doesn’t have any return type.
Which among the following is a possible way to overload a constructor?
A. Define default constructor, 1 parameter constructor and 2 parameter constructor
Which is executed automatically when the control reaches the end of the class scope?
B. Destructor
The special character related to destructor is
D. ~
A destructor is used to destroy the objects that have been created by a
C. Constructor
______ provides the flexibility of using different format of data at runtime depending upon the situation
A. Dynamic Initialization