General Questions

Question 1 :

A constructor that accepts __________ parameters is called the default constructor.


A). one
B). two
C). no
D). three
Answer : Option C

Question 2 :

What happens when a class with parameterized constructors and having no default constructor is used in a program and we create an object that needs a zero-argument constructor?


A). Compile-time error.
B). Preprocessing error.
C). Runtime error.
D). Runtime exception.
Answer : Option A

Question 3 :

Can a class have virtual destructor?


A). Yes
B). No
Answer : Option A

Question 4 :

Destructor has the same name as the constructor and it is preceded by ______ .


A). !
B). ?
C). ~
D). $
Answer : Option C

Question 5 :

For automatic objects, constructors and destructors are called each time the objects


A). enter and leave scope
B). inherit parent class
C). are constructed
D). are destroyed
Answer : Option A

Question 6 :

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


A). Create constructor
B). Object constructor
C). Dynamic constructor
D). Copy constructor
Answer : Option D

Question 7 :

Which of the following statement is correct?


A). Constructor has the same name as that of the class.
B). Destructor has the same name as that of the class with a tilde symbol at the beginning.
C). Both A and B.
D). Destructor has the same name as the first member function of the class.
Answer : Option C

Question 8 :

Which of the following statement is incorrect?


A). Constructor is a member function of the class.
B). The compiler always provides a zero argument constructor.
C). It is necessary that a constructor in a class should always be public.
D). Both B and C.
Answer : Option D

Question 9 :

When are the Global objects destroyed?


A). When the control comes out of the block in which they are being used.
B). When the program terminates.
C). When the control comes out of the function in which they are being used.
D). As soon as local objects die.
Answer : Option B

Question 10 :

Copy constructor must receive its arguments by __________ .


A). either pass-by-value or pass-by-reference
B). only pass-by-value
C). only pass-by-reference
D). only pass by address
Answer : Option C

Question 11 :

A function with the same name as the class, but preceded with a tilde character (~) is called __________ of that class.


A). constructor
B). destructor
C). function
D). object
Answer : Option B

Question 12 :

A union that has no constructor can be initialized with another union of __________ type.


A). different
B). same
C). virtual
D). class
Answer : Option B

Question 13 :

Which of the following gets called when an object goes out of scope?


A). constructor
B). destructor
C). main
D). virtual function
Answer : Option B

Question 14 :

Which of the following statement is correct?


A). Destructor destroys only integer data members of the object.
B). Destructor destroys only float data members of the object.
C). Destructor destroys only pointer data members of the object.
D). Destructor destroys the complete object.
Answer : Option D

Question 15 :

__________ used to make a copy of one class object from another class object of the same class type.


A). constructor
B). copy constructor
C). destructor
D). default constructor
Answer : Option B

Question 16 :

Constructors __________ to allow different approaches of object construction.


A). cannot overloaded
B). can be overloaded
C). can be called
D). can be nested
Answer : Option B

Question 17 :

Which of the following statement is correct?


A). A destructor has the same name as the class in which it is present.
B). A destructor has a different name than the class in which it is present.
C). A destructor always returns an integer.
D). A destructor can be overloaded.
Answer : Option A

Question 18 :

Which of the following cannot be declared as virtual?


A). Constructor
B). Destructor
C). Data Members
D). Both A and C
Answer : Option D

Question 19 :

If the copy constructor receives its arguments by value, the copy constructor would


A). call one-argument constructor of the class
B). work without any problem
C). call itself recursively
D). call zero-argument constructor
Answer : Option C

Question 20 :

Which of the following are NOT provided by the compiler by default?


A). Zero-argument Constructor
B). Destructor
C). Copy Constructor
D). Copy Destructor
Answer : Option D

Question 21 :

It is a __________ error to pass arguments to a destructor.


A). logical
B). virtual
C). syntax
D). linker
Answer : Option C

Question 22 :

If the programmer does not explicitly provide a destructor, then which of the following creates an empty destructor?


A). Preprocessor
B). Compiler
C). Linker
D). main() function
Answer : Option B

Question 23 :

A __________ is a constructor that either has no parameters, or if it has parameters, all the parameters have default values.


A). default constructor
B). copy constructor
C). Both A and B
D). None of these
Answer : Option A

Question 24 :

How many default constructors per class are possible?


A). Only one
B). Two
C). Three
D). Unlimited
Answer : Option A

Question 25 :

Which of the following statement is correct about destructors?


A). A destructor has void return type.
B). A destructor has integer return type.
C). A destructor has no return type.
D). A destructors return type is always same as that of main().
Answer : Option C

Question 26 :

Which of the following statement is correct?


A). A constructor has the same name as the class in which it is present.
B). A constructor has a different name than the class in which it is present.
C). A constructor always returns an integer.
D). A constructor cannot be overloaded.
Answer : Option A

Question 27 :

Which of the following implicitly creates a default constructor when the programmer does not explicitly define at least one constructor for a class?


A). Preprocessor
B). Linker
C). Loader
D). Compiler
Answer : Option D

Question 28 :

A destructor takes __________ arguments.


A). one
B). two
C). three
D). no
Answer : Option D

Question 29 :

Destructor calls are made in which order of the corresponding constructor calls?


A). Reverse order
B). Forward order
C). Depends on how the object is constructed
D). Depends on how many objects are constructed
Answer : Option A

Question 30 :

Which of the following never requires any arguments?


A). Member function
B). Friend function
C). Default constructor
D). const function
Answer : Option C

Question 31 :

A class's __________ is called when an object is destroyed.


A). constructor
B). destructor
C). assignment function
D). copy constructor
Answer : Option B

Question 32 :

Destructors __________ for automatic objects if the program terminates with a call to function exit or function abort.


A). are called
B). are inherited
C). are not called
D). are created
Answer : Option C

Question 33 :

Which of the following statement is correct?


A). A constructor of a derived class can access any public and protected member of the base class.
B). Constructor cannot be inherited but the derived class can call them.
C). A constructor of a derived class cannot access any public and protected member of the base class.
D). Both A and B.
Answer : Option D

Question 34 :

Which of the following statements are correct?


A). Constructor is always called explicitly.
B). Constructor is called either implicitly or explicitly, whereas destructor is always called implicitly.
C). Destructor is always called explicitly.
D). Constructor and destructor functions are not called at all as they are always inline.
Answer : Option B

Question 35 :

How many times a constructor is called in the life-time of an object?


A). Only once
B). Twice
C). Thrice
D). Depends on the way of creation of object
Answer : Option A

Question 36 :

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


A). constructor
B). virtual function
C). destructor
D). main
Answer : Option A

Question 37 :

To ensure that every object in the array receives a destructor call, always delete memory allocated as an array with operator __________ .


A). destructor
B). delete
C). delete[]
D). kill[]
E). free[]
Answer : Option C

Question 38 :

Which of the following statement is correct about constructors?


A). A constructor has a return type.
B). A constructor cannot contain a function call.
C). A constructor has no return type.
D). A constructor has a void return type.
Answer : Option C

Question 39 :

Which of the following statement is correct whenever an object goes out of scope?


A). The default constructor of the object is called.
B). The parameterized destructor is called.
C). The default destructor of the object is called.
D). None of the above.
Answer : Option C