CLASSES
Superclasses and Subclasses
8.1.3
8.1.2.2
final
Classes
A class can be declared
final
 if its definition is complete and no subclasses are
desired or required. A compile time error occurs if the name of a
final
 class
appears in the
extends
 clause ( 8.1.3) of another
class
 declaration; this implies
that a
final
 class cannot have any subclasses. A compile time error occurs if a
class is declared both
final
 and
abstract
, because the implementation of such a
class could never be completed ( 8.1.2.1).
Because a
final
 class never has any subclasses, the methods of a
final
 class
are never overridden ( 8.4.6.1).
8.1.3   Superclasses and Subclasses
The optional
extends
 clause in a class declaration specifies the
direct superclass
of the current class. A class is said to be a
direct subclass
 of the class it extends.
The direct superclass is the class from whose implementation the implementation
of the current class is derived. The
extends
 clause must not appear in the defini 
tion of the class
java.lang.Object
 ( 20.1), because it is the primordial class
and has no direct superclass. If the class declaration for any other class has no
extends
 clause, then the class has the class
java.lang.Object
 as its implicit
direct superclass.
Super:
extends
ClassType
The following is repeated from  4.3 to make the presentation here clearer:
ClassType:
TypeName
The
ClassType
 must name an accessible ( 6.6) class type, or a compile time
error occurs. All classes in the current package are accessible. Classes in other
packages are accessible if the host system permits access to the package ( 7.2)
and the class is declared
public
. If the specified
ClassType
names a class that is
final
 ( 8.1.2.2), then a compile time error occurs;
final
 classes are not allowed
to have subclasses.
In the example:
class Point { int x, y; }
final class ColoredPoint extends Point { int color; }
class Colored3DPoint extends ColoredPoint { int z; } //
error
the relationships are as follows:
133






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