Where do new Java objects get created?

Prepare for the MuleSoft Integration Architect exam. Study with flashcards and multiple-choice questions, each offering hints and explanations to deepen understanding. Ace your exam with our focused preparation tools!

Multiple Choice

Where do new Java objects get created?

Explanation:
New objects are created in the heap, specifically in the Eden area of the young generation. When you instantiate a new object, the JVM allocates it there so it can be efficiently garbage collected. The young generation is designed for rapid collection, so most new objects are short-lived. If an object survives several garbage collections, it’s promoted to the old generation for longer-lived objects. The stack holds method frames and local primitive values or references, not the objects themselves. PermGen (in older JVMs) stores class metadata, not instances; modern JVMs use Metaspace for that.

New objects are created in the heap, specifically in the Eden area of the young generation. When you instantiate a new object, the JVM allocates it there so it can be efficiently garbage collected. The young generation is designed for rapid collection, so most new objects are short-lived. If an object survives several garbage collections, it’s promoted to the old generation for longer-lived objects. The stack holds method frames and local primitive values or references, not the objects themselves. PermGen (in older JVMs) stores class metadata, not instances; modern JVMs use Metaspace for that.

Subscribe

Get the latest from Passetra

You can unsubscribe at any time. Read our privacy policy