1.

Which is the condition that must be followed if the array of objects is declared without initialization, only with size of array?(a) The class should have separate constructor for each object(b) The class must have no constructors(c) The class should not have any member function(d) The class must have a default or zero argument constructorThis question was addressed to me during an interview.My question is from Object Array topic in division Object of Object Oriented Programming

Answer»

The correct answer is (d) The class MUST have a default or zero argument constructor

Explanation: The class must have a default/zero argument constructor. Since the declaration is done by only specifying the size of ARRAY, the class must have default a construct to be called by default to reserve MEMORY for each object. Also, we can’t specify the ARGUMENTS in this type of declaration HENCE the class should provide a default initialization.



Discussion

No Comment Found

Related InterviewSolutions