Overriden methods : overridden method « Object Oriented « SCJP

Home
SCJP
1.Java Source And Data Type
2.Operators
3.Modifiers
4.Type Casting
5.Statements
6.Object Oriented
7.Thread
8.Utility Classes
9.File
SCJP » Object Oriented » overridden method 
6.4.1.Overriden methods
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-abstractsubclass.

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

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

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

public method may be overridden only by a public method.


Illegal overridden method access

default method may not be overridden by a private method.

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

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.
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.