Question: Assume a base, Base has a derived class, Sub .. Also, assume a method called methodX() is defined in Base and overridden in Sub .
Assume a base, Base has a derived class, Sub.. Also, assume a method called methodX() is defined in Base and overridden in Sub. For simplicity, let's say the only thing this method does is to print out "Base" if Base's methodX() is called and "Sub" if the Sub's methodX() is called.
main() has these lines, in this order, exactly, (and all other lines are correct and unrelated to these) :
Base b = new Base(); Sub s = new Sub(); b = s; s.methodX(); b.methodX();
Check the true statements (there may be one or more):
| A. It will print: Sub Base |
| B. There are no compiler errors or warnings. |
| C. There will be a compiler warning which is not fatal, and main() will still run. |
| D. It will print: Base Sub |
| E. It will print: Sub Sub
|
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
