8.1.5
Class Body and Member Declarations
CLASSES
8.1.5 Class Body and Member Declarations
A
class body
may contain declarations of members of the class, that is, fields
( 8.3) and methods ( 8.4). A class body may also contain static initializers ( 8.5)
and declarations of constructors ( 8.6) for the class.
ClassBody:
{
ClassBodyDeclarations
opt
}
ClassBodyDeclarations:
ClassBodyDeclaration
ClassBodyDeclarations ClassBodyDeclaration
ClassBodyDeclaration:
ClassMemberDeclaration
StaticInitializer
ConstructorDeclaration
ClassMemberDeclaration:
FieldDeclaration
MethodDeclaration
The scope of the name of a member declared in or inherited by a class type is the
entire body of the class type declaration.
8.2 Class Members
The members of a class type are all of the following:
Members inherited from its direct superclass ( 8.1.3), except in class
Object
,
which has no direct superclass
Members inherited from any direct superinterfaces ( 8.1.4)
Members declared in the body of the class ( 8.1.5)
Members of a class that are declared
private
are not inherited by subclasses
of that class. Only members of a class that are declared
protected
or
public
are
inherited by subclasses declared in a package other than the one in which the class
is declared.
Constructors and static initializers are not members and therefore are not
inherited.
The example:
138
footer
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