Home
MCQS
C/C MCQ Quiz Hub
C Programming -Constructors and Destructors
Choose a topic to test your knowledge and improve your C/C skills
1. A constructor that accepts __________ parameters is called the default constructor.
one
two
no
three
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?
Compile-time error.
Preprocessing error.
Runtime error.
Runtime exception.
3. Destructor has the same name as the constructor and it is preceded by ______ .
!
?
~
$
4. For automatic objects, constructors and destructors are called each time the objects
enter and leave scope
inherit parent class
are constructed
are destroyed
5. Which constructor function is designed to copy objects of the same class type?
Create constructor
Object constructor
Dynamic constructor
Copy constructor
6. Which of the following statement is correct?
Constructor has the same name as that of the class.
Destructor has the same name as that of the class with a tilde symbol at the beginning.
Both A and B.
Destructor has the same name as the first member function of the class.
7. Which of the following statement is incorrect?
Constructor is a member function of the class.
The compiler always provides a zero argument constructor.
It is necessary that a constructor in a class should always be public.
Both B and C.
8. When are the Global objects destroyed?
When the control comes out of the block in which they are being used.
When the program terminates.
When the control comes out of the function in which they are being used.
As soon as local objects die.
9. Copy constructor must receive its arguments by __________ .
either pass-by-value or pass-by-reference
only pass-by-value
only pass-by-reference
only pass by address
10. A function with the same name as the class, but preceded with a tilde character (~) is called __________ of that class.
constructor
destructor
function
object
11. A union that has no constructor can be initialized with another union of __________ type.
different
same
virtual
class
12. Which of the following gets called when an object goes out of scope?
constructor
destructor
main
virtual function
13. Which of the following statement is correct?
Destructor destroys only integer data members of the object.
Destructor destroys only float data members of the object.
Destructor destroys only pointer data members of the object.
Destructor destroys the complete object.
14. ________ used to make a copy of one class object from another class object of the same class type.
constructor
copy constructor
destructor
default constructor
15. Constructors __________ to allow different approaches of object construction.
cannot overloaded
can be overloaded
can be called
can be nested
16. Which of the following statement is correct?
A destructor has the same name as the class in which it is present.
A destructor has a different name than the class in which it is present.
A destructor always returns an integer.
A destructor can be overloaded.
17. Which of the following cannot be declared as virtual?
Constructor
Destructor
Data Members
Both A and C
18. If the copy constructor receives its arguments by value, the copy constructor would
call one-argument constructor of the class
work without any problem
call itself recursively
call zero-argument constructor
19. Which of the following are NOT provided by the compiler by default?
Zero-argument Constructor
Destructor
Copy Constructor
Copy Destructor
20. It is a __________ error to pass arguments to a destructor.
logical
virtual
syntax
linker
21. If the programmer does not explicitly provide a destructor, then which of the following creates an empty destructor?
Preprocessor
Compiler
Linker
main() function
22. 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
23. How many default constructors per class are possible?
Only one
Two
Three
Unlimited
24. 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().
25. 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.
26. 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
27. A destructor takes __________ arguments.
one
two
three
no
28. 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
29. Which of the following never requires any arguments?
Member function
Friend function
Default constructor
const function
30. A class's __________ is called when an object is destroyed.
constructor
destructor
assignment function
copy constructor
31. 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
32. 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.
33. 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.
34. 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
35. Which of the following gets called when an object is being created?
constructor
virtual function
destructor
main
36. 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[]
37. 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.
38. 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.
Submit