Java Virtual Machine (JVM) is used to execute architectural neutral byte code.…

2019

Java Virtual Machine (JVM) is used to execute architectural neutral byte code. Which of the following is needed by the JVM  for execution of Java Code?

  1. A.

    Class loader only

  2. B.

    Class loader and Java Interpreter

  3. C.

    Class loader, Java Interpreter and API

  4. D.

    Java Interpreter only

Attempted by 275 students.

Show answer & explanation

Correct answer: B

Answer: Class loader and Java interpreter

Why this is correct: The JVM's core responsibilities are to load compiled bytecode and to execute it. That requires both a class loader and an execution engine (the Java interpreter, often combined with a JIT compiler).

  • Class loader: locates, reads, and brings .class bytecode into the JVM so it can be used at runtime.

  • Execution engine / Java interpreter: reads JVM bytecode and executes it. Modern JVMs typically include a JIT compiler that converts frequently used bytecode into native machine code for better performance.

  • Standard APIs and class libraries: supplied by the Java runtime environment (JRE). They provide useful classes for programs but are not the minimal components the JVM needs to load and execute bytecode.

Why the other choices are incorrect:

  • Class loader only: Missing the execution engine needed to run bytecode.

  • Class loader, Java interpreter and API: Includes the correct components but adds APIs, which are part of the runtime libraries (JRE) and not strictly required by the JVM's core execution mechanism.

  • Java Interpreter only: Missing the class loader that brings classes into the JVM for execution.

A video solution is available for this question — log in and enroll to watch it.

Explore the full course: Mppsc Assistant Professor