CLASSES
Examples of Method Declarations
8.4.8
either they have different return types or one has a return type and the other
is
void
. Moreover, a compile time error occurs if the inherited method that
is not
abstract
 has a
throws
 clause that conflicts ( 8.4.4) with that of any
other of the inherited methods.
If none of the inherited methods is not
abstract
, then the class is necessarily
an
abstract
 class and is considered to inherit all the
abstract
 methods. A
compile time error occurs if, for any two such inherited methods, either they
have different return types or one has a return type and the other is
void
. (The
throws
 clauses do not cause errors in this case.)
It is not possible for two or more inherited methods with the same signature not to
be
abstract
, because methods that are not
abstract
 are inherited only from the
direct superclass, not from superinterfaces.
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.7   Overloading
If two methods of a class (whether both declared in the same class, or both inher 
ited by a class, or one declared and one inherited) have the same name but differ 
ent signatures, 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 meth 
ods with the same name but different signatures.
Methods are overridden on a signature by signature basis. If, for example, a
class declares two
public
 methods with the same name, and a subclass overrides
one of them, the subclass still inherits the other method. In this respect, Java dif 
fers from C++.
When a method is invoked ( 15.11), the number of actual arguments and the
compile time types of the arguments are used, at compile time, to determine the
signature of the method that will be invoked ( 15.11.2). If the method that is to be
invoked is an instance method, the actual method to be invoked will be determined
at run time, using dynamic method lookup ( 15.11.4).
8.4.8   Examples of Method Declarations
The following examples illustrate some (possibly subtle) points about method
declarations.
167






footer




 

 

 

 

 Home | About Us | Network | Services | Support | FAQ | Control Panel | Order Online | Sitemap | Contact

java hosting

 

Our partners: PHP: Hypertext Preprocessor Best Web Hosting Java Web Hosting Inexpensive Web Hosting  Jsp Web Hosting

Cheapest Web Hosting Jsp Hosting Cheap Hosting

Visionwebhosting.net Business web hosting division of Web Design Plus. All rights reserved