Polymorphic Variables

Even if we accept the need for static typing, object-oriented languages introduce a new twist into the static/dynamic typing distinction.

The is-a relationship asserts that an instance of a child class is in all important respects a representative of the parent class. Thus, the value of a child class should be able to be used where we expect a parent class.

This means that a variable declared as one type, say Mammal, should be able to hold a value derived from a subtype, such as Dog.

[audio] [real] Text to accompany slide5, in Chapter 10 of An Introduction to Object-Oriented Programming