Suppose class Child is derived from class Parent that was in turn derived from class GrandParent. This question concerns order of calls to constructors and destructors for these three classes. Declare an object of class Child. We know that Child, Parent and GrandParent constructors are called. In what order are these constructors are called? When the time comes to destroy the class Child object, we know that Child, Parent and GrandParent destructors are called. In what order are these destructor called?

What will be an ideal response?

The constructors are called starting with the constructor for the ultimate base class, class GrandParent, then the first derived class, class Parent, then the object’s class, class Child. At destruction of the Child object, destructors are called in reverse order of their invocation.

Computer Science & Information Technology

You might also like to view...

A JavaFX Button’s event handler receives a(n) ________, which indicates that the Button was clicked.

a. ButtonEvent b. ObjectEvent c. ControlEvent d. ActionEvent

Computer Science & Information Technology

What is the difference between a data type and a variable?

What will be an ideal response?

Computer Science & Information Technology