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
Get step-by-step solutions from verified subject matter experts
