Fundamentals · Hard · Free
What are stack frames, references, and object headers in Java (high level)?
FresherFundamentalsOOP & Language Fundamentals
Stack, heap, references
Local variables and call frames live on the stack (per thread). Objects live on the heap; variables hold references (like pointers without arithmetic). Object header stores metadata (class pointer, hash, lock state).
diagram
stack frame: ref ──▶ heap object { header, fields... }- Primitives on stack (usually); objects always on heap.
- Passing reference copies the pointer—mutations visible to caller.
Connect to GC: only reachable heap objects survive collection.