Java Reference
In-Depth Information
Declaring Methods
A method declaration generally has the following things:
 Name for the method
 Return type of that method
 List of arguments or parameters
 Body for that method which actually defines the operations to be performed on
data.
The general form for method declaration is
returnType MethodName ( argument-list)
{
Body for the method;
}
A class can have following types of variables:
 Instance variables: The variables defined inside a class but outside any method
are known as instance variables. As a class is loaded, these variables are instantiated.
These variables can be accessed from any method or block including constructor of
that particular class.
 Local variables: The variables defined inside any method, constructor or blocks
are known as local variables. The variable are declared and initialized within a
particular method and destroyed with the completion of that method.
 Class variables: These variables are defined inside a class but outside any
method with a single difference that they are declared using Static keyword.
In the above given example name, color, age are data member and eating, hungry, walking,
running, sleeping all these are functions.
Search WWH ::




Custom Search