Which of the following are TRUE about constructors in C++? (A) A constructor…

2024

Which of the following are TRUE about constructors in C++?
(A) A constructor can be overloaded.
(B) A constructor does not have a return type.
(C) A constructor must be declared as a friend function.
(D) A constructor is called when an object is destroyed.
Choose the correct answer from the options given below :

Answer: D. (A), (B) Only.Answer: The true statements are: 'A constructor can be overloaded' and 'A constructor does not have a return type.' Reasons: 'A constructor can be overloaded'…

  1. A.

    (B), (C), (D) Only

  2. B.

    (B), (C) Only

  3. C.

    (A), (B), (C) Only

  4. D.

    (A), (B) Only.

Attempted by 207 students.

Show answer & explanation

Correct answer: D

Answer: The true statements are: 'A constructor can be overloaded' and 'A constructor does not have a return type.'

Reasons:

  • 'A constructor can be overloaded' — True. A class may define multiple constructors that differ in their parameter lists to allow different ways of initializing objects.

  • 'A constructor does not have a return type' — True. Constructors are special member functions and are not declared with any return type (not even void).

  • 'A constructor must be declared as a friend function' — False. Constructors are normal special member functions of the class; they are not required to be friend functions.

  • 'A constructor is called when an object is destroyed' — False. The destructor is invoked when an object is destroyed, not the constructor.

A video solution is available for this question — log in and enroll to watch it.

Explore the full course: Mppsc Assistant Professor Computer Science Paper 2

Loading lesson…