Constructors and Destructors in C ++ Programming MCQ Questions and Answers

1. What is a constructor in C++?
A) A function that handles file I/O
B) A special member function used to initialize objects
C) A function that deallocates memory
D) A function template for operator overloading
Answer: B) A special member function used to initialize objects

2. What is a destructor in C++?
A) A special member function used to clean up before object destruction
B) A function that allocates memory for objects
C) A function to copy objects
D) A function to overload operators
Answer: A) A special member function used to clean up before object destruction

3. Which of the following is true about constructors?
A) Constructors have a return type void
B) Constructors have no return type, not even void
C) Constructors must be named init()
D) Constructors cannot be overloaded
Answer: B) Constructors have no return type, not even void

4. Which of the following is the correct syntax for a default constructor?
A) class X { X(); }; and X::X() {} — and it may be user-defined or compiler-provided
B) class X { void X(); };
C) class X { int X(); };
D) class X { X(void) : {} };
Answer: A) class X { X(); }; and X::X() {} — and it may be user-defined or compiler-provided

5. When is a default constructor called?
A) When object is explicitly deleted
B) When an object is created without explicit initialization
C) When a function returns a pointer
D) When virtual functions are invoked
Answer: B) When an object is created without explicit initialization

6. What is a parameterized constructor?
A) A constructor that takes no arguments
B) A constructor that is always inline
C) A constructor that takes one or more parameters to initialize the object
D) A constructor used only in templates
Answer: C) A constructor that takes one or more parameters to initialize the object

7. What is a copy constructor?
A) A constructor that converts other types to the class type
B) A constructor that creates a new object as a copy of an existing object
C) A constructor that moves resources from another object
D) A destructor disguised as a constructor
Answer: B) A constructor that creates a new object as a copy of an existing object

8. Which is the correct signature for a typical copy constructor?
A) X(X a);
B) X& X(const X&);
C) X(X&&);
D) X(const X &obj);
Answer: D) X(const X &obj);

9. When is the copy constructor called?
A) When returning by value, passing by reference, or explicitly creating a copy — sometimes optimized away
B) When an object is initialized from another object of the same class
C) When a pointer to object is assigned
D) When deleting an object with delete
Answer: B) When an object is initialized from another object of the same class

10. What is a move constructor?
A) A constructor that copies contents across different types
B) A constructor that is used for virtual inheritance only
C) A constructor that transfers resources from a temporary (rvalue) object
D) A synonym for copy constructor
Answer: C) A constructor that transfers resources from a temporary (rvalue) object

11. Which of the following is the correct signature for a move constructor?
A) X(X &);
B) X(X&& other);
C) X(const X& other) noexcept;
D) X(move X);
Answer: B) X(X&& other);

12. What does the explicit keyword do when applied to a constructor?
A) Makes constructor inline
B) Prevents implicit conversions and copy-initialization using that constructor
C) Makes constructor virtual
D) Forces move semantics
Answer: B) Prevents implicit conversions and copy-initialization using that constructor

13. Which constructor will be called if a class has both default and parameterized constructors and an object is declared like X obj;?
A) Parameterized constructor
B) Copy constructor
C) Default constructor
D) Move constructor
Answer: C) Default constructor

14. Can constructors be const, volatile, or virtual?
A) Yes to all three
B) Constructors cannot be const, volatile, or virtual
C) They can be const but not virtual
D) They can be virtual but not const
Answer: B) Constructors cannot be const, volatile, or virtual

15. What is constructor delegation (C++11 feature)?
A) Using one constructor to call another constructor in the same class
B) Delegating object creation to a factory function
C) Using base class constructor implicitly
D) A method to reduce code duplication by calling another constructor from a constructor
Answer: D) A method to reduce code duplication by calling another constructor from a constructor

16. How do you delegate constructors in C++11?
A) Using the delegate keyword
B) Using a static helper function only
C) By calling another constructor in the member initializer list: X(): X(0) {}
D) By calling base class constructor from derived class only
Answer: C) By calling another constructor in the member initializer list: X(): X(0) {}

17. Which of the following is true about destructors?
A) Destructors can be overloaded
B) There is exactly one destructor per class and it cannot be overloaded
C) Destructors must return bool
D) Destructors must be static
Answer: B) There is exactly one destructor per class and it cannot be overloaded

18. What is the syntax of a destructor?
A) ~X;
B) X::~X() {}
C) ~X() { /* cleanup */ } inside the class or X::~X() {} outside
D) destructor X() {}
Answer: C) ~X() { /* cleanup */ } inside the class or X::~X() {} outside

19. When is the destructor called?
A) When the object is created
B) When an object goes out of scope, is deleted, or when program ends for global/static objects
C) When passing object by value
D) When copying an object
Answer: B) When an object goes out of scope, is deleted, or when program ends for global/static objects

20. Can a destructor be virtual and why?
A) No, destructors cannot be virtual
B) Yes — to ensure proper cleanup when deleting derived objects through base class pointers
C) Yes — but only in final classes
D) No — virtual destructors are undefined behavior
Answer: B) Yes — to ensure proper cleanup when deleting derived objects through base class pointers

21. What happens if a base class destructor is not virtual and you delete a derived object through a base pointer?
A) Derived destructor always runs regardless
B) Program always crashes
C) Only the base destructor runs — derived destructor is not called, causing resource leak
D) Compiler error
Answer: C) Only the base destructor runs — derived destructor is not called, causing resource leak

22. Is it allowed to have an empty body destructor defined as ~X() = default;?
A) No — = default only applies to constructors
B) Yes — = default can be used for destructor to request compiler-generated destructor
C) No — destructors must be user-defined
D) Only for POD types
Answer: B) Yes — = default can be used for destructor to request compiler-generated destructor

23. What does = delete do if used on a constructor?
A) Marks destructor as deleted
B) Prevents the constructor from being used (deleted function)
C) Optimizes constructor calls
D) Forces implicit conversion
Answer: B) Prevents the constructor from being used (deleted function)

24. Which of the following constructor forms will prevent copy initialization via =?
A) X::X()
B) X(const X&)
C) explicit X(int)
D) X(int) without explicit
Answer: C) explicit X(int)

25. How can you prevent objects of a class from being copied?
A) By making destructor private
B) By deleting or making private the copy constructor and copy assignment operator
C) By making constructor static
D) By making all members const
Answer: B) By deleting or making private the copy constructor and copy assignment operator

26. What does the rule of three state?
A) You must have three constructors always
B) If a class defines one of (destructor, copy constructor, copy assignment), it should probably explicitly define all three
C) You must overload operator+ three times
D) It applies only to templates
Answer: B) If a class defines one of (destructor, copy constructor, copy assignment), it should probably explicitly define all three

27. What is the “rule of five” in modern C++?
A) Rule about five constructors only
B) If a class defines any of destructor, copy constructor, copy assignment, move constructor, or move assignment, consider declaring all five appropriately
C) Rule about five inheritance levels
D) Rule about five templates
Answer: B) If a class defines any of destructor, copy constructor, copy assignment, move constructor, or move assignment, consider declaring all five appropriately

28. Which operator is usually defined together with copy constructor?
A) operator*
B) Copy assignment operator (operator=)
C) operator->
D) operator!
Answer: B) Copy assignment operator (operator=)

29. What will the compiler provide if no constructors are declared?
A) No object can be created
B) A default constructor, copy constructor, move constructor (C++11+), copy assignment, move assignment, and destructor may be implicitly declared
C) Only destructor is provided
D) Only copy assignment is provided
Answer: B) A default constructor, copy constructor, move constructor (C++11+), copy assignment, move assignment, and destructor may be implicitly declared

30. What is a trivial constructor?
A) A constructor that throws exceptions
B) A constructor that performs no action and is eligible for certain optimizations (POD-like behavior)
C) A constructor declared private
D) A constructor with static linkage
Answer: B) A constructor that performs no action and is eligible for certain optimizations (POD-like behavior)

31. Can a constructor throw exceptions?
A) No — constructors are not allowed to throw
B) Yes — constructors can throw exceptions; if thrown, object construction fails and destructors of fully constructed subobjects run
C) Only if marked noexcept(false)
D) Only if virtual
Answer: B) Yes — constructors can throw exceptions; if thrown, object construction fails and destructors of fully constructed subobjects run

32. What is noexcept used for with constructors?
A) To enable virtual dispatch
B) To declare that the constructor will not throw exceptions, enabling optimizations and safer move operations
C) To suppress all warnings
D) To force copy constructor selection
Answer: B) To declare that the constructor will not throw exceptions, enabling optimizations and safer move operations

33. Given class X { X(int=5); }; Is this a default constructor?
A) No, because it has a parameter
B) Yes — it is a default constructor because all parameters have default values
C) Only with C++98
D) Only with explicit keyword
Answer: B) Yes — it is a default constructor because all parameters have default values

34. What is the member initializer list used for in constructors?
A) To list virtual functions
B) To initialize member variables (and call base class constructors) before constructor body executes
C) To finalize memory layout
D) To allocate stack memory
Answer: B) To initialize member variables (and call base class constructors) before constructor body executes

35. Which is better for initializing members in constructors?
A) Assigning inside constructor body always
B) Using member initializer list — especially for const/reference members or when member constructors are expensive
C) Using global variables
D) Using malloc in constructor body
Answer: B) Using member initializer list — especially for const/reference members or when member constructors are expensive

36. What happens if you initialize members both in the constructor initializer list and in the body?
A) Body initializations override list
B) Members are initialized in the initializer list first; assignments in body are later assignments, not initializations
C) Undefined behavior
D) Compiler error
Answer: B) Members are initialized in the initializer list first; assignments in body are later assignments, not initializations

37. Which of these cannot be initialized in the constructor body and must be initialized in the initializer list?
A) Non-static data members
B) Reference members and const members
C) Static members
D) Pointers
Answer: B) Reference members and const members

38. Which order are members initialized in?
A) Alphabetical order of member names
B) Order of declaration in the class
C) Order in initializer list
D) Random order chosen by compiler
Answer: B) Order of declaration in the class

39. If initializer list order differs from declaration order, what happens?
A) Compiler reorders to match initializer list
B) Members are still initialized in declaration order; mismatched lists may trigger warnings
C) Runtime error
D) The last one in the list is used
Answer: B) Members are still initialized in declaration order; mismatched lists may trigger warnings

40. Can constructors be static?
A) Yes, for utility creation
B) No — constructors cannot be declared static
C) Only in C++11
D) Only when inline
Answer: B) No — constructors cannot be declared static

41. Can you declare a constructor as private?
A) No — constructors must be public
B) Yes — using private constructors enables patterns like singleton or factory methods
C) Only default constructors can be private
D) Only in templates
Answer: B) Yes — using private constructors enables patterns like singleton or factory methods

42. What is the effect of making destructor protected or private?
A) It always crashes the program
B) It prevents deletion through base class pointer and can be used to control object lifetime
C) It makes it virtual automatically
D) It converts destructor into constructor
Answer: B) It prevents deletion through base class pointer and can be used to control object lifetime

43. What is a delegating constructor chain?
A) Calling base class constructors only
B) A sequence where one constructor calls another constructor of the same class, which may call another, etc.
C) A constructor calling global functions only
D) A constructor chain across derived classes
Answer: B) A sequence where one constructor calls another constructor of the same class, which may call another, etc.

44. If a class has a user-defined move constructor, will the compiler still generate a copy constructor?
A) No, never
B) It depends — presence of user-declared move constructor inhibits implicit copy constructor generation in some situations
C) Yes, always
D) Only if class is trivial
Answer: B) It depends — presence of user-declared move constructor inhibits implicit copy constructor generation in some situations

45. Which of these is a shallow copy?
A) Copy that duplicates deep structures
B) Copy that duplicates pointer values but not the data they point to
C) Copy that uses move semantics
D) Copy that clones virtual table pointers only
Answer: B) Copy that duplicates pointer values but not the data they point to

46. What is deep copy?
A) Copy that fails for pointers
B) Copy that duplicates all pointed-to data so both objects have independent resources
C) Copy that uses memcpy always
D) Copy that uses move constructor
Answer: B) Copy that duplicates all pointed-to data so both objects have independent resources

47. Which constructor type would you implement to perform deep copy?
A) Default constructor
B) Copy constructor and copy assignment operator
C) Destructor only
D) Move constructor only
Answer: B) Copy constructor and copy assignment operator

48. Which of the following will invoke the copy constructor?
A) X a; X b = std::move(a);
B) X a; X b = a;
C) X a; X b(a);
D) Both B and C
Answer: D) Both B and C

49. Which of the following will preferentially call the move constructor (if available)?
A) X a; X b = a;
B) X a; X b(a);
C) X b = X(); or X b = std::move(a); (rvalues / explicit move)
D) X a; X b = &a;
Answer: C) X b = X(); or X b = std::move(a); (rvalues / explicit move)

50. What is placement new?
A) A misplaced operator new
B) A form of new allowing construction of an object in pre-allocated memory
C) A destructor helper
D) A replacement for malloc that always throws
Answer: B) A form of new allowing construction of an object in pre-allocated memory

51. Which destructor is called when using placement new and then explicit destructor call?
A) No destructor is called automatically for placement new; you must call destructor explicitly
B) Destructor must be called manually when using placement new — automatic call does not happen
C) Compiler calls destructor automatically twice
D) Placement new forbids destructor calls
Answer: B) Destructor must be called manually when using placement new — automatic call does not happen

52. What is a synthesized (implicit) copy constructor?
A) A constructor written by programmer via macros
B) A copy constructor automatically declared by the compiler if user hasn’t declared one
C) A constructor that must be virtual
D) A deprecated feature removed in C++11
Answer: B) A copy constructor automatically declared by the compiler if user hasn’t declared one

53. Under what condition will the compiler suppress generating a move constructor?
A) If user declared destructor, copy constructor, or copy assignment operator (pre-C++11 rules updated in C++11/14)
B) If copy operations or destructor are user-declared, implicit move may be suppressed
C) Move is always generated regardless
D) Move is never generated
Answer: B) If copy operations or destructor are user-declared, implicit move may be suppressed

54. Which one of these is correct about constructors in inheritance?
A) Derived constructors automatically call derived default constructors of base
B) Base class constructors are called before derived class constructor body executes; derived must explicitly call non-default base constructors in initializer list
C) Base constructors are never invoked
D) Derived constructors call base destructors first
Answer: B) Base class constructors are called before derived class constructor body executes; derived must explicitly call non-default base constructors in initializer list

55. Which order are destructors called in inheritance?
A) Derived class destructor first, then base class destructor
B) Base destructor first, then derived destructor
C) Derived class destructor runs first, then base class destructor
D) Random order
Answer: C) Derived class destructor runs first, then base class destructor

56. What is the purpose of virtual destructor in base classes?
A) To prevent copying
B) To ensure derived class destructors execute when deleting via base pointer
C) To optimize destructor calls
D) To avoid any destructor being called
Answer: B) To ensure derived class destructors execute when deleting via base pointer

57. What is an implicitly-defined destructor?
A) Destructor written by programmer using keyword implicit
B) Destructor generated by the compiler if not user-declared
C) Destructor that is always virtual
D) Destructor that is templated
Answer: B) Destructor generated by the compiler if not user-declared

58. Which of the following is true for virtual constructors?
A) C++ has built-in virtual constructors
B) C++ does not have virtual constructors; factory patterns are used instead
C) Virtual constructors are declared as virtual X()
D) Virtual constructors automatically allocate memory
Answer: B) C++ does not have virtual constructors; factory patterns are used instead

59. How to emulate virtual constructor behavior?
A) Using virtual keyword on constructor
B) Using virtual clone functions or factory methods (e.g., virtual X* clone() const)
C) Using dynamic_cast inside constructor
D) Using static constructors
Answer: B) Using virtual clone functions or factory methods (e.g., virtual X* clone() const)

60. Can you explicitly call a constructor on an already constructed object?
A) Yes, by invoking constructor name like a function
B) No — you cannot call a constructor directly on an already constructed object; use placement new after destroying it manually
C) Yes, only in debug mode
D) Only for POD types
Answer: B) No — you cannot call a constructor directly on an already constructed object; use placement new after destroying it manually

61. What happens to static data members during construction?
A) They are constructed for each object separately
B) Static data members are initialized once before program execution or on first use (depending on storage and C++ standard rules)
C) They are never initialized
D) They are destroyed before object construction
Answer: B) Static data members are initialized once before program execution or on first use (depending on storage and C++ standard rules)

62. Is it legal to throw exceptions from destructors?
A) Always fine
B) Throwing exceptions from destructors during stack unwinding can cause std::terminate; generally avoid throwing from destructors
C) Only if destructor is virtual
D) Only in C++98
Answer: B) Throwing exceptions from destructors during stack unwinding can cause std::terminate; generally avoid throwing from destructors

63. What is meant by “constructor is explicit” with single argument?
A) It will be ignored by the compiler
B) It prevents implicit conversions from that single-argument type to the class type
C) It makes the constructor private
D) It makes it virtual
Answer: B) It prevents implicit conversions from that single-argument type to the class type

64. Which of the following correctly initialises base class using member initializer list?
A) Derived(): Base {}
B) Derived(): Base() {}
C) Derived() : Base(5) {} if Base has a constructor taking int
D) Derived() { Base(5); }
Answer: C) Derived() : Base(5) {} if Base has a constructor taking int

65. How can constructor overloading be achieved?
A) By using different return types
B) By declaring multiple constructors with different parameter lists
C) By making constructors virtual
D) By changing class name
Answer: B) By declaring multiple constructors with different parameter lists

66. What is the outcome of class X { X() = delete; }; and X x;?
A) Program compiles and runs fine
B) Compilation error because default constructor is deleted and cannot be used
C) Runtime error only
D) It uses implicit default constructor anyway
Answer: B) Compilation error because default constructor is deleted and cannot be used

67. Which of the following is true regarding constructor exceptions and resource management?
A) Constructors don’t need RAII since they can’t fail
B) Use RAII — ensure resources are wrapped in objects so if constructor throws, destructors free already acquired resources
C) Exceptions in constructors are ignored
D) Use global destructors instead
Answer: B) Use RAII — ensure resources are wrapped in objects so if constructor throws, destructors free already acquired resources

68. If a class has a const data member, where must it be initialized?
A) In destructor
B) In the member initializer list (or at declaration in-class if C++11 and later)
C) With assignment in constructor body only
D) It cannot be initialized
Answer: B) In the member initializer list (or at declaration in-class if C++11 and later)

69. How do you suppress generation of copy assignment operator?
A) By declaring it private or = delete
B) Making destructor virtual
C) Using explicit keyword on copy constructor
D) By writing in-class friend declarations only
Answer: A) By declaring it private or = delete

70. Which of the following is NOT part of the canonical form of a C++ class (Rule of Three / Five)?
A) Destructor
B) Copy constructor
C) operator+
D) Copy assignment operator
Answer: C) operator+

71. When using inheritance, how should you define destructors for base classes meant to be polymorphic?
A) Leave them default non-virtual
B) Declare the base destructor virtual to ensure proper cleanup
C) Make them private always
D) Make them static
Answer: B) Declare the base destructor virtual to ensure proper cleanup

72. Which of these initializations invokes the default constructor?
A) X a(5);
B) X a = X(5);
C) X a = X();
D) X a;
Answer: D) X a;

73. What is aggregate initialization in context of constructors?
A) Using constructors only for aggregates
B) Initialization of aggregate types (no user-declared constructors) via brace-enclosed initializer lists
C) Only for classes with virtual functions
D) Deprecated in C++11
Answer: B) Initialization of aggregate types (no user-declared constructors) via brace-enclosed initializer lists

74. Which of the following is true about constructors and default arguments?
A) Default arguments are ignored in constructors
B) Constructors can have default arguments and may serve as default constructors if all params have defaults
C) Constructors cannot have default arguments if class has virtual functions
D) Default arguments make constructors inline automatically
Answer: B) Constructors can have default arguments and may serve as default constructors if all params have defaults

75. What is the typical use of private constructors in design patterns?
A) Prevent deriving from class
B) Implement Singleton or factory patterns to control instantiation
C) Speed up compilation
D) Allow multiple inheritance only
Answer: B) Implement Singleton or factory patterns to control instantiation

76. Consider class X { public: X() { f(); } void f(); }; — what caution must be taken when calling f() inside constructor?
A) Nothing — it’s always safe
B) If f() is virtual, calling it from constructor invokes base-class version, not derived override
C) Virtual dispatch works normally
D) Constructor cannot call member functions at all
Answer: B) If f() is virtual, calling it from constructor invokes base-class version, not derived override

77. What is the order of initialization for base class and member objects?
A) Members, then base classes, then constructor body
B) Base classes first (in inheritance order), then data members (in declaration order), then constructor body
C) Constructor body first, then base and members
D) Random order
Answer: B) Base classes first (in inheritance order), then data members (in declaration order), then constructor body

78. Which one of these will prevent implicit copy initialization X x = y;?
A) X(const X&) = default;
B) X(const X&) = delete; or explicit X(const X&)
C) ~X() = default;
D) X(X&&) = default;
Answer: B) X(const X&) = delete; or explicit X(const X&)

79. If a copy constructor is declared but not defined and then used, what happens?
A) Linker error or undefined reference at link time
B) Runtime exception
C) Linker error because symbol definition missing
D) Compiler warns but builds an implicit version
Answer: C) Linker error because symbol definition missing

80. In context of constructors, what is in-class member initialization (C++11)?
A) A way to declare variables inside constructor only
B) Provide default member initializers at declaration, e.g., int x = 5; inside class
C) Initializes static members automatically
D) Only works for POD types
Answer: B) Provide default member initializers at declaration, e.g., int x = 5; inside class

81. Which of the following is true about initializing base class subobject in derived constructor?
A) Base class constructor is called after derived constructor body
B) Derived class initializer list is used to call a particular base class constructor
C) You cannot choose which base constructor is called
D) Base constructors are ignored for polymorphic classes
Answer: B) Derived class initializer list is used to call a particular base class constructor

82. What is the correct way to prevent object slicing when copying polymorphic objects?
A) Use copy constructor only
B) Use pointers/references to base and clone virtual function to copy objects polymorphically
C) Make constructors private
D) Use static_cast always
Answer: B) Use pointers/references to base and clone virtual function to copy objects polymorphically

83. What is a copy-and-swap idiom?
A) A method of swapping global variables
B) An assignment implementation pattern using copy construction then swap to provide strong exception-safety
C) A deprecated move operation
D) A destructor aliasing technique
Answer: B) An assignment implementation pattern using copy construction then swap to provide strong exception-safety

84. In copy-and-swap, which function is typically required?
A) operator+
B) A swap() function (member or friend) that swaps internal resources
C) Virtual destructor only
D) Placement new only
Answer: B) A swap() function (member or friend) that swaps internal resources

85. How does std::move affect constructor selection?
A) Forces call to copy constructor
B) Converts lvalue to rvalue reference allowing move constructor to be selected
C) Calls destructor instead
D) Prevents any constructor being called
Answer: B) Converts lvalue to rvalue reference allowing move constructor to be selected

86. When is the implicitly-declared move constructor noexcept?
A) Always noexcept
B) If all member and base move constructors are noexcept (or nothrow)
C) Never noexcept
D) Only in C++98
Answer: B) If all member and base move constructors are noexcept (or nothrow)

87. What effect does = default; have on a constructor definition?
A) Deletes it
B) Requests compiler to generate the defaulted implementation (may be inline/optimizable)
C) Forces non-virtual behavior
D) Forces noexcept always
Answer: B) Requests compiler to generate the defaulted implementation (may be inline/optimizable)

88. For a class having raw pointer members requiring dynamic allocation, what should be provided?
A) Only default constructor
B) Destructor, copy constructor, and copy assignment operator (or use RAII and smart pointers instead)
C) Only destructor — rest compiler-generated are fine always
D) Only move constructor
Answer: B) Destructor, copy constructor, and copy assignment operator (or use RAII and smart pointers instead)

89. Which of these statements about constructors and templates is true?
A) Template classes cannot have constructors
B) Templates can have constructors, and each instantiation produces corresponding constructor definitions
C) Constructors in templates must be inline only
D) Constructor templates must be static
Answer: B) Templates can have constructors, and each instantiation produces corresponding constructor definitions

90. In multiple inheritance, which constructor is invoked first?
A) Constructors of the last base in the list
B) Constructors of bases are invoked in the order of declaration in the derived class base-list
C) Derived constructor first
D) Random order
Answer: B) Constructors of bases are invoked in the order of declaration in the derived class base-list

91. If a member object has no user-declared default constructor and you don’t initialize it in derived class initializer list, what happens?
A) Member will be zero-initialized always
B) Compilation error because no suitable constructor exists for the member
C) Program runs but behavior undefined
D) Member will be default constructed by compiler anyway
Answer: B) Compilation error because no suitable constructor exists for the member

92. What is the significance of the order of destructor calls for class members?
A) Members are destroyed in reverse order of their construction (reverse of declaration order)
B) Members are destroyed in reverse order of declaration (i.e., reverse of initialization order)
C) Members are destroyed alphabetically
D) Members are destroyed randomly
Answer: B) Members are destroyed in reverse order of declaration (i.e., reverse of initialization order)

93. What is a implicitly-declared default constructor?
A) Default constructor declared by explicit only
B) A default constructor the compiler declares if no user-declared constructors exist
C) Default constructor declared when copy ctor is provided
D) Only generated when destructor is virtual
Answer: B) A default constructor the compiler declares if no user-declared constructors exist

94. How can constructors affect object lifetime when using smart pointers?
A) Constructors have no effect with smart pointers
B) Smart pointers manage lifetime; constructors still initialize resources and influence how smart pointers manage them
C) Smart pointers bypass constructors always
D) Constructing an object in a smart pointer is illegal
Answer: B) Smart pointers manage lifetime; constructors still initialize resources and influence how smart pointers manage them

95. Which of the following best practice helps avoid defining custom copy/move/destructor logic?
A) Use raw pointers only
B) Prefer standard library types (std::string, std::vector, smart pointers) — RAII — instead of raw resource management
C) Avoid constructors entirely
D) Use goto in constructors for cleanup
Answer: B) Prefer standard library types (std::string, std::vector, smart pointers) — RAII — instead of raw resource management

96. What is the behavior when throwing from a constructor and catching outside?
A) Object destructor runs as if constructed fully
B) If constructor throws, object is not constructed; destructors of members that were fully constructed are called, then exception propagates
C) No destructors are called for any members
D) The object exists but is partially initialized and usable
Answer: B) If constructor throws, object is not constructed; destructors of members that were fully constructed are called, then exception propagates

97. Which special member functions can be implicitly defined as deleted by the compiler?
A) Only destructor
B) Copy/move constructors or assignment operators can be implicitly defined as deleted in presence of certain members (e.g., reference members, non-copyable members)
C) operator+ only
D) All constructors always defined
Answer: B) Copy/move constructors or assignment operators can be implicitly defined as deleted in presence of certain members (e.g., reference members, non-copyable members)

98. Which statement is true about constructors and virtual functions when called from constructor/destructor?
A) Virtual calls behave normally and call most-derived override
B) Virtual functions called from constructors/destructors are resolved to the current class — not to derived overrides
C) Virtual calls cause runtime error
D) Virtual functions cannot be called at all in constructors/destructors
Answer: B) Virtual functions called from constructors/destructors are resolved to the current class — not to derived overrides

99. What is the significance of marking constructors explicit for single-argument constructors?
A) Slower code generation
B) Avoids unintended implicit conversions that might lead to bugs
C) Forces use of new keyword
D) Only affects destructors
Answer: B) Avoids unintended implicit conversions that might lead to bugs

100. Which of the following is the recommended modern approach to handle copy/move semantics and resource management?
A) Manually manage memory with raw pointers only
B) Prefer RAII with smart pointers (std::unique_ptr, std::shared_ptr), and define move semantics; rely on defaulted special members when appropriate
C) Avoid destructors entirely
D) Use global singletons for resource management
Answer: B) Prefer RAII with smart pointers (std::unique_ptr, std::shared_ptr), and define move semantics; rely on defaulted special members when appropriate