QuestionQ229

Working with Selected Classes from the Java API

Which statement is true about Java byte code?

  • A It can run on any platform.
  • B It can run on any platform only if it was compiled for that platform.
  • C It can run on any platform that has the Java Runtime Environment.
  • D It can run on any platform that has a Java compiler.
  • E It can run on any platform only if that platform has both the Java Runtime Environment and a Java compiler.
Explanation

Java source code is compiled once into platform-independent bytecode (.class files), and that bytecode can be executed on any platform for which a Java Runtime Environment (containing a Java Virtual Machine) is available; the JVM interprets or JIT-compiles the bytecode into native instructions for that specific platform at run time. Bytecode does not need to be recompiled per platform, and a Java compiler is not required at the execution site — only a JRE is needed to run already-compiled bytecode.

Community Discussion

No comments yet. Be the first to start the discussion!