Module: | Core Architecture, Basics & Control Flow
Q7: Consider the following statements regarding Java's Platform Independence feature:
1. Platform independence in Java is achieved because the compiler generates an intermediate class file containing standardized bytecode.
2. The Java Virtual Machine (JVM) is a universally identical, platform-independent software package that runs seamlessly on any operating system without modification.
3. The size and representation of primitive data types in Java are fixed and remain identical across all hardware architectures.
Which of the above statements is/are correct?
2. The Java Virtual Machine (JVM) is a universally identical, platform-independent software package that runs seamlessly on any operating system without modification.
3. The size and representation of primitive data types in Java are fixed and remain identical across all hardware architectures.
Which of the above statements is/are correct?
✅ Correct Answer: B
🎯 Quick Answer:
The correct combination is 1 and 3. Statement 2 is incorrect because while Java code is platform-independent, the JVM itself is inherently platform-dependent (different JVM installations exist for Windows, Linux, and macOS).Structural Breakdown: The platform execution workflow involves: Java Source Code (.java) to Java Compiler to Bytecode (.class) to OS-Specific JVM to OS-Specific Machine Code.
Historical/Related Context: Before Java, if a developer wrote a C program, the integer data type might take 16 bits on a legacy machine and 32 bits on a newer machine, leading to unpredictable software behavior.
Java eliminated this by strictly defining its data specifications (for example, an int is always a 32-bit signed two's complement integer, regardless of the host hardware). Causal Reasoning: The JVM acts as a real-time translator.
Because it must convert the universal bytecode into the specific machine language of the host operating system, the JVM binary itself must be uniquely compiled and tailored by Oracle for that specific host environment.