An overridden method is replaced by the overriding method unless the overridden method is deliberately invoked from within the subclass. : overridden method « Object Oriented « SCJP






public class MainClass {
  public static void main(String[] argv) {
    MySubclass sub = new MySubclass();
    sub.calc(1, 2);
    System.out.println();
  }
}

class MyClass {

  public void calc(int i, int j) {
    System.out.println("a");
  }
}

class MySubclass extends MyClass {

  public void calc(int i, int j) {
    System.out.println("b");
  }

}








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.