Java 2 Primer Plus

   

Java™ 2 Primer Plus

By Steven Haines, Steve Potts

Table of Contents
Chapter 7.  Inheritance

Subclasses can redefine inherited methods as well as define new ones. The process of redefining methods that a subclass would otherwise inherit is called overriding methods. The signature and the return type of the method must be identical in both the super class and the subclass.

The subclass's overridden method's access modifier must be the same or less restrictive than in the super class. Thus, the subclass can make a protected method public, but it cannot make it private.

The final constraint for overridden methods is that they can and must override the super class's abstract methods (unless the subclass is defined to be abstract as well).


       
    Top
     

    Категории