Overriden methods : overridden method « Object Oriented « SCJP






The overriding method Must have the same argument list.

The overriding method Must have the same return type.

The overriding method Must not have a more restrictive access modifier.

The overriding method May have a less restrictive access modifier.

The overriding method Must not throw new or broader checked exceptions.

The overriding method May throw fewer or narrower checked exceptions, or any unchecked exception.

final methods cannot be overridden.

Polymorphic method invocations apply only to overridden instance methods.

Methods can be overridden or overloaded; constructors can be overloaded but not overridden.

Abstract methods must be overridden by the first concrete (non-abstract) subclass.

Only inherited methods may be overridden, and private methods are not inherited.

A subclass uses super.overriddenMethodName() to call the superclass version of an overridden method.

The accessibility of the overriding method must not be more restrictive than the overridden method.
If the overridden method is public, the overriding method must also be public.
If the overridden method is protected, the overriding method must be public or protected.
If the overridden method is package access, the overriding method must be public, package access, or protected.
If the superclass method is private, it is not inherited by its subclasses, and overriding is not an issue. 

Legal overridden method access

A default method may be overridden by a default, protected, or public method.

A protected method may be overridden by a protected or public method.

A public method may be overridden only by a public method.


Illegal overridden method access

A default method may not be overridden by a private method.

A protected method may not be overridden by a default or private method.

A public method may not be overridden by a protected, default, or private method.








6.4.overridden method
6.4.1.Overriden methods
6.4.2.Overridden Methods
6.4.3.Using the same method name with identical arguments and return type is known as overriding.
6.4.4.Java specifies that methods may not be overridden to be more private.
6.4.5.Static methods can't be overridden
6.4.6.Exceptions and Overriding
6.4.7.Method Overriding: modify the behavior of one of these methods to suit your new class.
6.4.8.Each method in a parent class can be overridden at most once in any one subclass.
6.4.9.Overriding methods must have argument lists of identical type and order.
6.4.10.The return type of an overriding method must be identical to that of the method it overrides.
6.4.11.Methods marked final may not be overridden.
6.4.12.The accessibility must not be more restrictive than that of the original method for overridden method.
6.4.13.Method may throw only checked exception types that are the same as, or subclasses of, exception types thrown by the original method for overridden method.
6.4.14.Overridden methods support subclass of the return type of the superclass version.
6.4.15.Invoking Overridden Methods with super.
6.4.16.super invokes the version of this method that is next up the hierarchical tree
6.4.17.An overridden method is replaced by the overriding method unless the overridden method is deliberately invoked from within the subclass.
6.4.18.The overriding and overridden methods must have the same return type.
6.4.19.The throws clause of the overriding method must only specify exceptions that are in the throws clause of the overridden method.