Q2: How does Java achieve platform independence?
Java achieves platform independence through the concept of 'Write Once, Run Anywhere' (WORA). The Java compiler (javac) translates source code into an intermediate format called Bytecode (.class). Bytecode is platform-neutral; platform-specific JVM implementations interpret or JIT-compile this bytecode into native machine code.
Key Takeaways
- Source code compiles to platform-neutral Bytecode (
.class). - JVM implementations are platform-specific, making Java bytecode platform-independent.
Knowledge Check
Is the JVM itself platform-independent?