img
Inheritance interacts with encapsulation as well. If a given class encapsulates some
attributes, then any subclass will have the same attributes plus any that it adds as part of its
specialization (see Figure 2-2). This is a key concept that lets object-oriented programs grow
in complexity linearly rather than geometrically. A new subclass inherits all of the attributes
of all of its ancestors. It does not have unpredictable interactions with the majority of the rest
of the code in the system.
Polymorphism
Polymorphism (from Greek, meaning "many forms") is a feature that allows one interface to
be used for a general class of actions. The specific action is determined by the exact nature
FIGURE 2-2
Labrador inherits the encapsulation of all its superclasses
Search WWH :
Custom Search
Previous Page
Java SE 6 Topic Index
Next Page
Java SE 6 Bookmarks
Home