Question: what are the differences between heap and stack memory in java?
Answer: JVM has divided memory space between two parts one is Stack and another one is Heap space. Stack space is mainly used for storing order of method execution and local variables. Stack always stored blocks in LIFO order whereas heap memory used dynamic allocation for allocating and deallocating memory blocks.