Multiple choice

Which of the following statements is TRUE about constructors and destructors?

  1. A class must have a constructor and a destructor defined to make required variable initializations and to deallocate memory at the end.

  2. Both can be declared with arguments (parameterized)

  3. Both are invoked only once per object.

  4. The names of constructor and destructor can be anything.

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

The constructor and destructor of a class can be invoked (called) only once per object. An object of a class can call a normal method as many times as required but a constructor can be called just once. The same rule applies to the destructor also.