READING CHAPTER 13 SECTION 1 - *polymorphism* - OO programming feature that allows programmers to send the same message to objects from different classes - each class must define it's own implementation - the method that is actually called at runtime depends on the runtime class - helps write code that is easy to modify and extend - *polymorphic message* - a message whose execution differs depending on the receiving object - defining subclasses of programmer-defined classes - all classes automatically inherit from Object if they do not explicitly extend another class - modeling multiple classes - *unrelated classes* - classes that are not connected in an inheritance relationship - neither one is an ancestor or descendent of the other - also do not share a common ancestor (aside from Object) - if classes are related, ineffective design model - end up duplicating common code - use an inheritance hierarchy - if modeling two related classes, may require three classes when using inheritance - once class to model the common features - two more classes, one each to model the specific features - reserved word protected - public to descendent classes - private to everybody else - reserved word extends - from the idea that a subclass extends, or adds on to, it's superclass - inheritance class diagrams - for protected, use the pound/hash symbol (#) instead of - for private or + for public - do not show inherited data members and methods in subclasses - instead, use an inheritance arrow from the subclass to the superclass - except for - overridden methods (more later), which are included - methods that are defined separately in the subclasses Quick Check: 1. X is the subclass, Y is the superclass 2. The visibility modifier protected allows data members of a superclass to be accessible to the instances of a subclass.