A class is used as the template for creating objects. When an object is created, all fields and methods declared in the class are copied into an object. The combination of field values in an object is called object state. The methods provide object behavior. An object is also called an instance of a class.
Each object is created by using the operator new and a constructor that looks like a special kind of method. The primary duty of a constructor is to set an initial object state.
Let's us now have a closer look at Java classes and objects.