C/C MCQ Quiz Hub

C Programming -Constructors and Destructors

Choose a topic to test your knowledge and improve your C/C skills

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





✅ Correct Answer: 3

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?





✅ Correct Answer: 1

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





✅ Correct Answer: 3

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





✅ Correct Answer: 1

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





✅ Correct Answer: 4

Which of the following statement is correct?





✅ Correct Answer: 3

Which of the following statement is incorrect?





✅ Correct Answer: 4

When are the Global objects destroyed?





✅ Correct Answer: 2

Copy constructor must receive its arguments by __________ .





✅ Correct Answer: 3

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





✅ Correct Answer: 2

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





✅ Correct Answer: 2

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





✅ Correct Answer: 2

Which of the following statement is correct?





✅ Correct Answer: 4

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





✅ Correct Answer: 2

Constructors __________ to allow different approaches of object construction.





✅ Correct Answer: 2

Which of the following statement is correct?





✅ Correct Answer: 1

Which of the following cannot be declared as virtual?





✅ Correct Answer: 4

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





✅ Correct Answer: 3

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





✅ Correct Answer: 4

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





✅ Correct Answer: 3

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





✅ Correct Answer: 2

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





✅ Correct Answer: 1

How many default constructors per class are possible?





✅ Correct Answer: 1

Which of the following statement is correct about destructors?





✅ Correct Answer: 3

Which of the following statement is correct?





✅ Correct Answer: 1

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





✅ Correct Answer: 4

A destructor takes __________ arguments.





✅ Correct Answer: 4

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





✅ Correct Answer: 1

Which of the following never requires any arguments?





✅ Correct Answer: 3

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





✅ Correct Answer: 2

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





✅ Correct Answer: 3

Which of the following statement is correct?





✅ Correct Answer: 4

Which of the following statements are correct?





✅ Correct Answer: 2

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





✅ Correct Answer: 1

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





✅ Correct Answer: 1

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





✅ Correct Answer: 3

Which of the following statement is correct about constructors?





✅ Correct Answer: 3

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





✅ Correct Answer: 3