Home » Java » Running Java bytecode

Running Java bytecode

Posted by: admin December 28, 2021 Leave a comment

Questions:

I am studying for a Java certificate and I got a question that I know it could be really basic. However, I am not sure:

Question: Which statement is true about Java bytecode?

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 Java Runtime Environment and Java compiler.

I think (c) is the correct answer, assuming that the Java Runtime Environment is the interpreter.

Answers:

The answer would be C.

Java bytecode is already the compiled form of the Java source code, and the Java compiler is only available with the Java Software Development Kit (SDK). Once code has been compiled, it does not need to be compiled again.

All the system needs is the Java Runtime Environment (JRE) because the JRE is able to interpret the bytecode and run it on the system.

###

The Java Runtime Environment (JRE) is a software package which bundles the libraries (jars) and the Java Virtual Machine, and other components to run applications written in the Java. JVM is just a part of JRE distributions.

To execute any Java application, you need JRE installed in the machine. It’s the minimum requirement to run Java applications on any computer.

So, my answer would be C.