Module: | Core Architecture, Basics & Control Flow
Q4: Consider the following statements regarding Java Bytecode:
1. Java bytecode is an architecture-independent intermediate instruction set generated by the Java compiler from the source code.
2. The bytecode instructions are named as such because each operational code (opcode) strictly occupies a single byte of memory.
3. Bytecode can only be executed via line-by-line interpretation and cannot be compiled into native machine code during program execution.
Which of the above statements is/are correct?
2. The bytecode instructions are named as such because each operational code (opcode) strictly occupies a single byte of memory.
3. Bytecode can only be executed via line-by-line interpretation and cannot be compiled into native machine code during program execution.
Which of the above statements is/are correct?
✅ Correct Answer: B
🎯 Quick Answer:
The correct combination is 1 and 2. Statement 3 is incorrect because modern JVMs use a Just-In-Time (JIT) compiler to dynamically convert frequently executed bytecode into native machine code at runtime.It acts as the intermediary format between human-readable Java code and machine-specific binary code.
Structural Breakdown: A compiled Java file (.class) contains a magic number identifier, minor/major version details, a constant pool, access flags, and the actual bytecode opcodes representing the class's variables and methods.
Historical/Related Context: The design of bytecode was a revolutionary shift in the 1990s.
While older languages like C or C++ compiled directly to hardware-specific binaries, Java's intermediate bytecode allowed developers to distribute a single executable file that could run unchanged on Windows, Mac, or Solaris machines equipped with a JVM.
Causal Reasoning: Limiting the opcode size to a single byte keeps the compiled .class files highly compact.
This was historically vital for speeding up the transfer of Java Applets over slow 1990s dial-up internet connections.