Constructors and Destructors Mcqs

Our collections of Multiple choice questions and answers focuses on study of Constructors and Destructors in OOP. These questions are chosen from a collection of most authoritative and best reference books on OOP. Our aim is to prepare an individual for competitive exams like NTS, Web Developer | IOS Developer | Game Developer | Software House interviews and jobs, University and College entrance exams and various tests and job interviews. One should practice our Mcqs to assimilate Constructors and Destructors in OOP comprehensively.

2.
Which among the following is not a necessary condition for constructors?

Its name must be same as that of class

It must not have any return type

It must contain a definition body

It can contains arguments

5.
If a programmer defines a class and defines a default value parameterized constructor inside it.
He has not defined any default constructor. And then he try to create the object without passing arguments, which among the following will be correct?

It will not create the object (as parameterized constructor is used)

It will create the object (as the default arguments are passed )

It will not create the object ( as the default constructor is not defined )

It will create the object ( as at least some constructor is defined )

6.
If class C inherits class B. And B has inherited class A. Then while creating the object of class C, what will be the sequence of constructors getting called?

Constructor of C then B, finally of A

Constructor of A then C, finally of B

Constructor of C then A, finally B

Constructor of A then B, finally C

7.
In multiple inheritance, if class C inherits two classes A and B as follows, which class constructor will be called first:
class A{ };
class B{ };
class C: public A, public B{  };

A()

B()

C()

Can’t be determined

8.
Which among the following is true for copy constructor?

The argument object is passed by reference

It can be defined with zero arguments

Used when an object is passed by value to a function

Used when a function returns an object

9.
If the object is passed by value to a copy constructor:

Only public members will be accessible to be copied

That will work normally

Compiler will give out of memory error

Data stored in data members won’t be accessible

10.
Which object will be created first?
class student 
{  
    int marks;
};
student s1, s2, s3;

S1 then s2 then s3

S3 then s2 then s1

S2 then s3 then s1

All are created at same time

11.
Which among the following helps to create a temporary instance?

Implicit call to a default constructor

Explicit call to a copy constructor

Implicit call to a parameterized constructor

Explicit call to a constructor

12.
Which among the following is correct for the class defined below?
class student
{
 int marks;
 public: student(){}
 student(int x)
 { 
  marks=x; 
 }
};
main()
{
student s1(100);
student s2();
student s3=100;
return 0;

Object s3, syntax error

Only object s1 and s2 will be created

Program runs and all objects are created

Program will give compile time error

13.
For constructor overloading, each constructor must differ in ___________ and __________

Number of arguments and type of arguments

Number of arguments and return type

Return type and type of arguments

Return type and definition

15.
Choose the correct option for the following code.
class student
{
    int marks;
}
student s1;
student s2=2;

Object s1 should be passed with argument.

Object s2 should not be declared

Object s2 will not be created, but program runs

Program gives compile time error

0Shares
0
Scroll to Top