1.

Which among the following best describes the constructors?(a) A function which is called whenever an object is referenced(b) A function which is called whenever an object is created to initialize the members(c) A function which is called whenever an object is assigned to copy the values(d) A function which is called whenever an object is to be given values for membersThe question was asked by my school principal while I was bunking the class.This key question is from Execution of Constructor or Destructor topic in chapter Constructors and Destructors of Object Oriented Programming

Answer»

Correct choice is (b) A function which is called whenever an object is created to initialize the members

Easy EXPLANATION - The constructors are special type of functions which are called whenever an object is created. This is to initialize the DATA members of the CLASS. The constructor allocates memory SPACE for all the data members.



Discussion

No Comment Found

Related InterviewSolutions