1.

Which constructor will be called first from the classes involved in single inheritance from object of derived class?(a) Base class constructor(b) Derived class constructor(c) Both class constructors at a time(d) Runtime errorThis question was addressed to me during an interview.My doubt is from Single Level Inheritance topic in chapter Inheritance & its Types of Object Oriented Programming

Answer»

Right option is (a) Base class constructor

To EXPLAIN I would say: The base class constructor will be called first from the OBJECT of derived class constructor. When the derived class members are to be initialized and allocated memory, the base class members should ALSO be confirmed with the memory allocation.



Discussion

No Comment Found

Related InterviewSolutions