What is a Class?
All Java codes are defined in a class. A Class has variables and methods.
Variables are attributes which define the state of a class.
Methods are the place where the exact business logic has to be done. It contains a set of statements (or) instructions to satisfy the particular requirement.
Example:
view sourceprint?
1
public class Addition{ //Class name declaration
2
int a = 5; //Variable declaration
3
int b= 5;
4
public void add(){ //Method declaration
5
int c = a+b;
6
}
7
}