Object in Java with example


Java Object : Definition

An Onject is the basic unit of of object-oriented programming.There can be more than one instance of an object.

Objects are identified by its unique name. An Obect represents a particular instance of a class.

Each instance of an object can hold its own relevant data.

An Object is a collection of data members and associated member functions also known as methods.

Example:

MyProgram.java


Output:

5
6
  

When class is defined, only the specification for the object is defined; no memory or storage is allocated.