Java Reference
In-Depth Information
If the return type of the non-
abstract
method is not a subtype of the return type of
any of the other inherited methods, a compile-time unchecked warning occurs
A compile-time error occurs if the return type of the non-
abstract
method is not
A compile-time error occurs if the inherited method that is not
abstract
has a
throws
clause that conflicts (§
8.4.6
) with that of any other of the inherited meth-
ods.
• If all the inherited methods are
abstract
, then the class is necessarily an
abstract
class
and is considered to inherit all the
abstract
methods.
One of the inherited methods must be return-type-substitutable for every other in-
herited method; otherwise, a compile-time error occurs. (The
throws
clauses do not
cause errors in this case.)
There might be several paths by which the same method declaration might be inherited
from an interface. This fact causes no difficulty and never, of itself, results in a compile-
time error.
8.4.9. Overloading
If two methods of a class (whether both declared in the same class, or both inherited by a
class, or one declared and one inherited) have the same name but signatures that are not
override-equivalent, then the method name is said to be
overloaded
.
This fact causes no difficulty and never of itself results in a compile-time error. There is no
required relationship between the return types or between the
throws
clauses of two methods
with the same name, unless their signatures are override-equivalent.
When a method is invoked (§
15.12
), the number of actual arguments (and any explicit type
arguments) and the compile-time types of the arguments are used, at compile time, to de-
to be invoked is an instance method, the actual method to be invoked will be determined at
Example 8.4.9-1. Overloading
class Point {
float x, y;
void move(int dx, int dy) { x += dx; y += dy; }