In case of a person as object, corresponding states are name, color, height, age and
behaviors are eating, walking, running, etc.
Defining a class
Class is a user defined data type serving as a blueprint. A simple class is defined with the
Data members or fields declaration;
Methods or member functions declaration;
As data members and member functions are optional, so Java allows even an empty class.
Fields and Methods declaration
As we know, data is encapsulated in Java by placing its data members and member
functions inside a class. These variables are known as instance variables as they are created
as an object is instantiated. The method of declaring instance variables is same as local
This class has three instance variables one age of integer type and other two name and color
of string type.