How Objects Are Created by the JVM

Here are the steps performed by the JVM to make a new object:

  1. Allocate memory to hold the object.

  2. Walk up the class hierarchy to the top, via calling the constructor of the superclass from each higher-level class, for example, super() calls super() calls super(), all the way up to Object. Then start making an instance of each object going back down the inheritance hierarchy. So for a Frame object, this means

    1. Make an object of type Object.

    2. Make an object of type Component (although because Component is abstract this doesn't technically happen).

    3. Make object of type Container

    4. Make an object of type Window.

    5. Make an object of type Frame.

Here's an analogy that might help you understand this activity. In order for me to ...

Get PURE Java™ 2 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.