21. Which keyword is used to create a copy constructor in C++? A. copy B. constructor C. copy_constructor D. None of the above Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option C No explanation is given for this question Let's Discuss on Board
22. What is the purpose of using constructor initialization lists in C++? A. To override the default constructor B. To create multiple constructors for a class C. To initialize class members before the body of the constructor executes D. To define constructors with multiple arguments Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option C No explanation is given for this question Let's Discuss on Board
23. What is the destructor called automatically when an object is destroyed in C++? A. .~className() B. className::~() C. ~() D. ~className() Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option D No explanation is given for this question Let's Discuss on Board
24. Which keyword is used to prevent an object from being copied in C++? A. nocopy B. prevent_copy C. delete D. new Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option C No explanation is given for this question Let's Discuss on Board
25. What happens if a destructor is made private in a C++ class? A. It is a syntax error B. The destructor will still be called when needed C. It prevents object destruction D. The compiler will throw an error Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option D No explanation is given for this question Let's Discuss on Board
26. In C++, which type of constructor is called when an object is created without any arguments? A. Default constructor B. Parameterized constructor C. Copy constructor D. Destructor Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option A No explanation is given for this question Let's Discuss on Board
27. What is the primary purpose of the explicit keyword in a C++ constructor? A. To mark the constructor as static B. To specify the return type of the constructor C. To allow implicit type conversions D. To prevent implicit type conversions Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option D No explanation is given for this question Let's Discuss on Board
28. In C++, what is the order of constructor and destructor calls for a class hierarchy? A. Constructors: Derived to Base, Destructors: Base to Derived B. Constructors and Destructors follow the same order C. Constructors: Base to Derived, Destructors: Derived to Base D. Constructors: Derived to Base, Destructors: Derived to Base Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option C No explanation is given for this question Let's Discuss on Board
29. What happens if a constructor throws an exception in C++? A. The destructor is called to deallocate resources B. The object is not fully constructed C. The object is still constructed but may have undefined behavior D. None of the above Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option B No explanation is given for this question Let's Discuss on Board
30. In C++, which function cannot be inherited but can be overridden in a derived class? A. Default Constructor B. Parameterized Constructor C. Destructor D. Copy Constructor Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option C No explanation is given for this question Let's Discuss on Board