java http://lxm.cs.pku.edu.cn/

http://lxm.cs.pku.edu.cn/pku-uwe/webtech/unit4/JavaObjectModel.html#overloading

Overriding Methods

In the process of inheritance, in addition to being able to produce a new class based on an old one by adding additional features, it is possible to modify existing methods of the parent class.

If a method declared in a subclass with the same name, same return type and same number and type of arguments as in a superclass, then the new method is said to override the old one. (Compare to the method overloading.)

The following rules apply to overridden methods:

  An overriding method cannot be less accessible than the method it overrides.

  An overriding method cannot throw more exceptions than the method it overrides.

  A static method cannot be overridden to be non-static

Overloading Method Names*

Java, along with several other programming languages, allows you to reuse a method name for more than one method. In some circumstances, you might want to write several methods in the same class that do basically the same job with different arguments. (Compare to overriding methods.) For example

void f(int x) c

void f(int x, Date d) c

When you write code to call one of above methods, the appropriate one is chosen according to the type of argument or arguments you supply.

Two rules apply to overloaded methods:

  The return type of the methods can be different, but the argument lists of overloaded methods must differ.

  The argument lists of the calling statement must differ enough to allow unambiguous determination of the proper method to call.