The Department of Computer Science & Engineering |
STUART C. SHAPIRO: CSE
115 C
|
Can declare a variable to be of one class,
then make it a reference to an instance of a subclass.
When you send that object a message,
the message will be handled by the method appropriate to the
object,
not appropriate to the variable.
See Polymorphism demonstration and its documentation.
Also see the definition and use of Appetite
in Inheritance demonstration and its documentation.