The need to understand necessity of class and objects is classes and objects forms the building blocks of any java program.
What is an Object?
An object is nothing but a region of storage that defines state and behavior. Storage can be either memory or disk and state is a set of variables and the values they contain. Behavior is a set of methods and the logic they implement.
Thus, an object is a combination of data and code that acts upon it.
What is Class?
A class is a template from which objects are created. It means objects are instances of a class and the mechanism to create a new object is called instantiation.
Example of Class and Object
For an example consider an account class. A separate account object represents an account holder's details. Its state includes variables such as account holder name, Total amount etc.... The behavior of a class account is defined by methods withdraw amount, deposit amount, get balance etc...
Member of a class
There are two ways that an item can be a member of a class.
1) Static member
2) Instance member
Static member is defined for the class itself and exists independently of any object of that class.
Instance member is defined for objects of the class, thus it is bound to an instance of its class.