1.

What Are Stack And Heap? What Is Stored In Each Of These Memory Structures, And How Are They Interrelated?

Answer»
  • The stack is a PART of memory that contains information about nested method calls down to the current position in the program. It also contains all local VARIABLES and references to objects on the HEAP defined in currently executing methods.
  • This structure allows the runtime to return from the method knowing the address whence it was called, and also clear all local variables after EXITING the method. Every thread has its own stack.
  • The heap is a large BULK of memory intended for allocation of objects. When you create an object with the new keyword, it gets allocated on the heap. However, the reference to this object lives on the stack.



Discussion

No Comment Found