JVM Internals Quiz - Languages Java
Free practice quiz: JVM Internals (Languages Java). 53 multiple-choice questions with answers and explanations. Play online, no sign-up needed.
Play all 53 questions freeSample questions
Which component of the JVM is responsible for converting Java bytecode into machine code during runtime?
- Class Loader
- Execution Engine
- Garbage Collector
- Java Native Interface (JNI)
Show answer
Answer: B. Execution Engine
The Execution Engine is the core of the JVM responsible for executing the bytecode. It includes the Interpreter (which executes bytecode instruction by instruction) and the Just-In-Time (JIT) compiler (which compiles frequently used bytecode into native machine code for faster execution).
What is the primary function of the JIT (Just-In-Time) compiler within the JVM?
- To parse Java source code
- To load and link classes
- To convert bytecode into native machine code for performance optimization
- To manage garbage collection
Show answer
Answer: C. To convert bytecode into native machine code for performance optimization
The JIT compiler identifies frequently executed sections of bytecode (hotspots) and compiles them into native machine code. This compiled code is then executed directly by the CPU, significantly improving application performance compared to interpretation alone.
Which of the following garbage collection algorithms is known for its generational approach?
- Mark and Sweep
- Copying Collector
- Generational Garbage Collector
- Reference Counting
Show answer
Answer: C. Generational Garbage Collector
Generational garbage collectors are based on the hypothesis that most objects die young. They divide the heap into generations (e.g., Young Generation, Old Generation) and apply different collection strategies to each, optimizing the process.
Which of the following is NOT a phase of Java Class Loading?
- Loading
- Linking
- Execution
- Initialization
Show answer
Answer: C. Execution
Class loading involves three main phases: Loading (finding and loading the `.class` file), Linking (verifying, preparing, and resolving), and Initialization (executing static initializers). Execution is the overall process of running the Java program, not a specific phase of class loading itself.
What happens to objects that survive multiple garbage collection cycles in the young generation of a generational GC?
- They are immediately deallocated.
- They are promoted to the old generation.
- They are moved to a different heap space.
- They are marked for deletion in the next cycle.
Show answer
Answer: B. They are promoted to the old generation.
Generational garbage collectors move 'survivor' objects (those that have survived at least one minor collection) from the young generation to the old generation. This strategy is based on the observation that most objects die young, so objects that persist are more likely to live longer.