Constructors and Destructors Questions

Practice Constructors and Destructors MCQs with answers and explanations. Page 1 of 3.

Category
C++ Programming
Topic
Constructors and Destructors
Page
1 / 3
Mode
Practice

Questions

Open any question to view the answer and explanation.

C++ destructors: how many arguments does a destructor take?
Open
View answer
C++ object lifetime for automatic objects: constructors and destructors are called when objects…
Open
View answer
C++ destructors: which statement is correct about naming, return type, and overloading?
Open
View answer
C++ constructors: which statement is correct about naming, return type, and overloading?
Open
View answer
C++ destructors: which statement correctly describes what a destructor destroys?
Open
View answer
In C++ (object-oriented programming), can a class declare a virtual destructor? Explain your choice based on polymorphic deletion and best practices.
Open
View answer
Constructors vs. destructors in C++: which statement is correct about how they are invoked? Consider implicit calls at scope boundaries and possible explicit use in special cases.
Open
View answer
Which statement is correct about C++ destructors and their return type? Choose the precise language rule.
Open
View answer
C++ destructors: passing arguments to a destructor is considered which kind of error? Identify the compile-time classification.
Open
View answer
Which statements about C++ constructors in inheritance are correct? Consider access to base members and whether constructors are inherited or callable.
Open
View answer
Program termination via std::exit or std::abort: what happens to destructors of automatic (stack) objects in C++?
Open
View answer
When an object's lifetime ends in C++, which special member function of its class is invoked for cleanup?
Open
View answer
Order of destruction in C++: destructor calls occur in what relation to the order of the corresponding constructor calls?
Open
View answer
By C++ definition, a “default constructor” is a constructor that accepts how many parameters?
Open
View answer
Which statement about C++ constructors is incorrect? Evaluate the claims about compiler-provided constructors and required access level.
Open
View answer
C++ constructors: what happens if a class defines only parameterized constructors (no zero-argument/default constructor), but the program attempts to create an object that requires a no-argument constructor?
Open
View answer
C++ special members: the function whose name is the class name prefixed with a tilde (~) is called what?
Open
View answer
C++ unions: a union without any user-declared constructor can be initialized from another union of which type?
Open
View answer
C++ copy constructor design: if the copy constructor takes its parameter by value, what happens?
Open
View answer
C++ copy constructor parameter: how must a copy constructor receive its argument for correct behavior?
Open
View answer

Practice smarter

Solve a few questions daily and revisit weak topics regularly to improve accuracy.