Classes in Java

Class?

Class is template or blueprint.

The most important thing to understand about a class is that it defines a new data type.
Variables defined within a class are called instance variables because each instance of the class contains its copy of these variables.

 Class declaration Method:

class ClassName {

Instance Variables:

 type instanceVariable1;
 type instanceVariable2;
 .
.
.
 type instanceVariableN;


Methods in Class:



 type methodName1(parameterList){
 //body of method and code
 }


 type methodName2(parameterList){
 //body of method
 }
 .
.
.
 type methodNameN(parameterList){
 //body of method and code


 }
}

Declare Object of class:

Classname objectname = new classname();
For Example
Student stud = new Student();











Comments

Popular posts from this blog

Inheritance in Java

Operators in Java Language?

Type Casting or Conversion in Java