A programmer needs to run an application on Windows, macOS, and Linux without recompiling the source code for each operating system. Which of the following BEST describes how the Java programming language achieves this?
Java is an interpreted language that is sent as source code and translated line-by-line by each operating system.
Java code is compiled into bytecode that is executed by a Java Virtual Machine (JVM) on each platform.
Java code is compiled directly into a separate native machine code executable for each target operating system.
Java code is converted into a universal machine code that all CPUs can execute directly without a virtual machine.
The correct answer explains that Java code is compiled into an intermediate form called bytecode, not native machine code. This platform-neutral bytecode is then executed by a Java Virtual Machine (JVM), which is specific to each operating system. The JVM translates the bytecode into machine code that the local CPU can understand. This process allows Java to be a "write once, run anywhere" language.
Ask Bash
Bash is our AI bot, trained to help you pass your exam. AI Generated Content may display inaccurate information, always double-check anything important.
What is bytecode in Java?
Open an interactive chat with Bash
What is the Java Virtual Machine (JVM)?
Open an interactive chat with Bash
What does platform-independent mean in the context of Java?