The class is the core of java.It is the logical construct upon which the entire Java language is built because it defines the shape and nature of an object. As such,the class forms the basis for object oriented programming in Java.Any concept we want to implement in java program must be encapsulated within the a class.
A class can be defined as a template that describes the behaviour that object of its type.A class is the blueprint from which individual objects are created. A class can have any number of methods to access the value of various kinds of methods.
A class can contain any of the following variable type:-
- Local variable:-Variables defined inside methods, constructors or blocks are called local variables. The variable will be declared and initialized within the method and the variable will be destroyed when the method has completed.
- Instance Variable:-Instance variables are variables within a class but outside any method. These variables are instantiated when the class is loaded. Instance variables can be accessed from inside any method, constructor or blocks of that particular class.
- Class Variables:-Class variables are variables declared with in a class, outside any method, with the static keyword.
Syntax:- A class is declared by the use of the class keyword. The syntax is given as below:-