Java Zero to All All questionsPractise free
Interview questions › JVM Internals & Runtime › JVM Architecture

Walk me through the difference between class loading, linking, and initialization, and why the JVM separates them.

Level III · MidJVM Architecture
Answer

Loading reads the bytecode and creates a Class object on the heap; linking then verifies the bytecode, prepares static fields to their default values, and resolves symbolic references to direct pointers; initialization finally runs static initializers and static field assignments in source order. The separation lets the JVM defer expensive work and run initialization lazily and exactly once, on first active use, under a class-level lock. A practical consequence is that a class can be loaded and linked long before it is initialized, which is why static side effects don't fire until you actually touch the class.

Common mistakes
  • Saying class loading and initialization happen at the same time.
  • Not knowing static initializers run during initialization, on first active use.

Can you say this out loud in two minutes? Drill it in a timed mock interview, with flashcards and runnable code for JVM Architecture.

Practise free

More on JVM Architecture