CS 18000 Chapter 17: Polymorphism
Document Summary
Java allows a superclass variable to contain a reference to a subclass object. The compiler chooses the subclass implementation of any overridden methods. Declaring an abstract class means that it cannot be instantiated. But an abstract class may also include some implemented methods for default behavior. Some methods may be implemented (just like an interface) Methods are selected at runtime based on the class of the object references, not the class of the variable that holds the object reference. Binding refers to the connection between the name of the method and the method body being called. Programmer must be disciplined: the overridden methods should implement consistent or expected behavior. Methods may be declared abstract: provide only the header (no body, class must then be declared abstract. Methods in an interface are implicitly declared abstract.