What exactly is Java program's "flexibility" gained by storing objects on the heap memory?
By storing objects on the heap, the garbage collector can manage that objects life cycle and clean it up when it is no longer needed. This means you don't have to worry about it yourself, nor does the JVM need to keep a reference count of the object. All you need to keep an object alive is to have a strongly reachable reference which only requires 4 bytes (even on most 64-bit JVMs)
Note: With Escape Analysis, very short lived objects can be placed on the stack to reduce overhead.