An object stores its state in fields (variables in some programming languages) and exposes its behavior through methods (functions in some programming languages). Methods operate on an object’s internal state and serve as the primary mechanism for object-to-object communication.
Read moreWhen object is created in Java where is it stored?
That means, whenever you create an object as static or local, it gets stored in heap . All the class variable primitive or object references (which is just a pointer to location where object is stored i.e. heap) are also stored in heap.
Read more