October 2008
Beginner to intermediate
680 pages
16h 48m
English
In an earlier example, GraduateStudent and UndergraduateStudent objects were stored in a List collection that had been declared to hold Student objects. An element extracted from the List will be returned as a Student object. The extracted object hasn't "forgotten" what class to which it belongs. An object always retains its class identity; it's simply that we can refer to an object with various different reference variables, which might be declared to be of different types, and it's this phenomenon that affects which messages the compiler believes that an object is capable of responding to. To help illustrate this point, let's use an example.
If we instantiate ...
Read now
Unlock full access