C++ - QUESTIONS : PART 14
A __________ is a constructor that either has no parameters, or if it has parameters, all the parameters have default values.
default constructor
copy constructor
Both A and B
None of these
SHOW ANSWER
How many default constructors per class are possible?
Only one
Two
Three
Unlimited
SHOW ANSWER
Which of the following statement is correct about destructors?
A destructor has void return type.
A destructor has integer return type.
A destructor has no return type.
A destructors return type is always same as that of main().
A destructor has no return type.
SHOW ANSWER
Which of the following statement is correct?
A constructor has the same name as the class in which it is present.
A constructor has a different name than the class in which it is present.
A constructor always returns an integer.
A constructor cannot be overloaded.
A constructor has the same name as the class in which it is present.
SHOW ANSWER
Which of the following implicitly creates a default constructor when the programmer does not explicitly define at least one constructor for a class?
Preprocessor
Linker
Loader
Compiler
SHOW ANSWER
A destructor takes __________ arguments.
one
two
three
no
SHOW ANSWER
Destructor calls are made in which order of the corresponding constructor calls?
Reverse order
Forward order
Depends on how the object is constructed
Depends on how many objects are constructed
SHOW ANSWER
Which of the following never requires any arguments?
Member function
Friend function
Default constructor
const function
SHOW ANSWER
A class's __________ is called when an object is destroyed.
constructor
destructor
assignment function
copy constructor
SHOW ANSWER
Destructors __________ for automatic objects if the program terminates with a call to function exit or function abort.
are called
are inherited
are not called
are created
SHOW ANSWER
Which of the following statement is correct?
A constructor of a derived class can access any public and protected member of the base class.
Constructor cannot be inherited but the derived class can call them.
A constructor of a derived class cannot access any public and protected member of the base class.
Both A and B.
SHOW ANSWER
Which of the following statements are correct?
Constructor is always called explicitly.
Constructor is called either implicitly or explicitly, whereas destructor is always called implicitly.
Destructor is always called explicitly.
Constructor and destructor functions are not called at all as they are always inline.
Constructor is called either implicitly or explicitly, whereas destructor is always called implicitly.
SHOW ANSWER
How many times a constructor is called in the life-time of an object?
Only once
Twice
Thrice
Depends on the way of creation of object
SHOW ANSWER
Which of the following gets called when an object is being created?
constructor
virtual function
destructor
main
SHOW ANSWER
To ensure that every object in the array receives a destructor call, always delete memory allocated as an array with operator __________ .
destructor
delete
delete[]
kill[]
free[]
SHOW ANSWER
Which of the following statement is correct about constructors?
A constructor has a return type.
A constructor cannot contain a function call.
A constructor has no return type.
A constructor has a void return type.
A constructor has no return type.
SHOW ANSWER
Which of the following statement is correct whenever an object goes out of scope?
The default constructor of the object is called.
The parameterized destructor is called.
The default destructor of the object is called.
None of the above.
The default destructor of the object is called.
SHOW ANSWER
The explicit keyword is an optional decoration for the constructors that takes exactly_____argument.
No argument
Two
Three
One
SHOW ANSWER