Portability claim: “Java bytecode is machine-specific code.” Evaluate this statement about Java’s compilation target.

Difficulty: Easy

Correct Answer: Incorrect

Explanation:


Introduction / Context:
Java compiles source into bytecode stored in .class files. The core promise is “write once, run anywhere,” relying on a platform-specific JVM to execute the same bytecode across architectures.



Given Data / Assumptions:

  • Bytecode targets a virtual machine, not a physical CPU ISA.
  • Different OS/CPU platforms provide their own JVM implementations.
  • The same .class/.jar runs on any compatible JVM.



Concept / Approach:
Machine-specific code is native binary tied to an instruction set. Bytecode is an intermediate, machine-independent representation interpreted/JIT-compiled by the JVM at runtime to the host architecture.



Step-by-Step Solution:
Compile Hello.java to Hello.class.Copy to Windows, Linux, macOS.Run with their respective JVMs; observe identical behavior.Note no recompilation is required.Understand JIT produces machine-specific native code at runtime, not at compile time.



Verification / Alternative check:
Run the same JAR across platforms; bytecode remains unchanged.



Why Other Options Are Wrong:
It is not “correct for x86” or “Android only”; the concept is VM portability.



Common Pitfalls:
Confusing bytecode with native binaries; assuming portability implies identical performance.



Final Answer:
Incorrect

More Questions from JDBC, Java Server Pages, and MySQL

Discussion & Comments

No comments yet. Be the first to comment!
Join Discussion