Read the following case study and answer the questions given below by choosing the correct option: Java compilation is different from the compilation of other high-level languages. Other high-level languages use an interpreter or a compiler, but in Java the source code is first compiled to produce an intermediate code called the byte code. This byte code is platform independent and is a highly optimised set of instructions designed to be executed by the Java run-time system called the JVM (Java Virtual Machine). The JVM is a Java interpreter loaded into computer memory as soon as Java is loaded. The JVM is different for different platforms.
JAVA code is:
Topic: Compilation and interpretation
Try it
Pick an option and check your answer. The full worked answer is below either way.
Answer
(a) Compiled and interpreted.
Java uses BOTH stages, which is unusual and is exactly what the passage is explaining. First javac COMPILES the source into bytecode; then the JVM INTERPRETS that bytecode at run time. C++ is only compiled, and older BASIC was only interpreted — Java’s two-stage approach is what buys it portability, at a small cost in speed.
Compiled and interpreted.