1.

If there are 3 classes. Class C is derived from class B and B is derived from A, Which class destructor will be called at last if object of C is destroyed.(a) A(b) B(c) C(d) All togetherI had been asked this question in an interview.My question is based upon Multilevel Inheritance in division Inheritance & its Types of Object Oriented Programming

Answer» CORRECT answer is (a) A

Easiest explanation - The destructors are called in the reverse order of the constructors being called. Hence in MULTILEVEL inheritance, the constructors are created from PARENT to child, which leads to DESTRUCTION from child to parent. Hence CLASS A destructor will be called at last.


Discussion

No Comment Found

Related InterviewSolutions