Heap is used for dynamic memory allocation and it allocates the memory at runtime. In a heap, memory is allocated randomly and there is no limitation of size. In heap, you can allocate or de-allocate theblock many times as per user requirement. And accessing of the object is so difficult in comparison of the stack. It also takes much more time for memory allocation.
For Example