A java object is also known as the instance of the class. The process of assigning value to the object, reference variable or creating objects from a class is called instantiation.
An object is an instance of a class. A class is a template or blueprint from which objects are created. The object represents a real-life entity. So, an object is the instance or result of a class.
An object has 3 characters.
- State: States represents by variables, attributes, data, property and value of the object.
- Behaviour: Behavior represents the methods or functionality of the object.
- Identity: JVM assigned a unique ID to each object to identify.
Java Object Creation
Java provides multiple ways to create objects.
- By new keyword
- By Class class newInstance() method.
- By Constructor class newInstance() method
- By clone() method
- By deserialization