System Software: Question 9

Syllabus 5.2

Multiple choice AS 1 mark

Some high-level programming languages, such as Java, are described as "partially compiled and partially interpreted", rather than being purely compiled or purely interpreted.

Which of the following best describes what actually happens when a program written in such a language is translated and run?

Choose an answer to check it, then compare with the worked solution below.

Show worked solution Hide worked solution

Worked solution

Why A is correct

A language such as Java is translated in two genuinely separate stages. First, a compiler translates the whole program’s source code into an intermediate form called bytecode. This is not the target processor’s own machine code, but a standard, portable form that is not tied to any one specific processor. Second, when the program is actually run, a virtual machine (for example, the Java Virtual Machine) translates and executes this bytecode, interpreting it statement by statement. This is why the language is described as “partially compiled” (the first stage, source code to bytecode) “and partially interpreted” (the second stage, bytecode executed by the virtual machine).

Why the other options are wrong

  • B: This describes a language compiled directly into processor-specific machine code, with no intermediate bytecode stage and no virtual machine. This is how a purely compiled language works, not a partially compiled, partially interpreted one.
  • C: This describes a purely interpreted language, translated and executed statement by statement as it is written, with no separate compiling stage producing bytecode at all.
  • D: This mixes up the roles of a compiler, an assembler and a virtual machine. An assembler translates assembly language into machine code; it does not sit between a compiler and a virtual machine in this way.

Final answer

A. The source code is first compiled into bytecode, and this bytecode is then interpreted (or further translated) by a virtual machine each time the program is run.