Question: If a base class reference, p , points to a derived class instance, and both base and derived classes have a public method void doIt()

If a base class reference, p, points to a derived class instance, and both base and derived classes have a public method void doIt() which takes no parameters, then p.doIt() will ...:

A ... invoke the derived class version, because it is the object pointed to that determines which method is called.
B ... invoke the base class version, because the base class reference only knows about the base class version of doIt().
C ... invoke the base class version, because type coercion was not used to first coerce the base class reference to a derived class type.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!