2.4 Java Platform Features & Architecture

Key Takeaways

  • javac produces platform-neutral class files. A compatible JVM and runtime libraries let the same class files run on different systems.

  • In Oracle’s Java 8 distribution the JDK includes runtime components and development tools. The JRE includes the JVM, runtime libraries, and supporting files.

  • Java combines object orientation and encapsulation (private state behind public methods) with strong static typing checked at compile time

  • Automatic garbage collection reclaims unreachable heap objects without manual free/delete calls, while System.gc() is only a hint to the JVM

  • Java rejects raw pointer arithmetic, checks array indices at run time, and verifies class file constraints before a class is initialized.

Last updated: November 2026

Java Platform Features & Architecture

Domain 1 of the 1Z0-808 exam concludes with a conceptual objective: comparing and contrasting the features and components of Java—including platform independence, object orientation, encapsulation, strong typing, memory management, and runtime safety. Exam questions on this topic often mix accurate Java architecture facts with subtle myths (such as claiming that the JVM itself is platform-independent or that System.gc() forces immediate memory reclamation).

Platform Independence: "Write Once, Run Anywhere"

Traditional compiled languages such as C and C++ compile source code directly into CPU- and OS-specific machine instructions. A binary compiled for Linux x86-64 will not execute natively on Windows ARM64.

Java takes a two-stage approach often summarized as Write Once, Run Anywhere (WORA):

  1. Compile time: The javac compiler translates human-readable .java source code into Java bytecode (.class files)—a compact, platform-neutral intermediate instruction set.
  2. Runtime: A Java Virtual Machine (JVM) installed on the target operating system loads the .class files, verifies them, and executes them. A JVM implementation such as HotSpot can use an interpreter and a just-in-time (JIT) compiler, which translates selected bytecode into native machine instructions.

Important

Distinguish the artifact from the engine: Java bytecode (.class) is platform-independent, whereas the JVM implementation itself is platform-dependent. You download a Windows JVM for Windows and a Linux JVM for Linux so both can run compatible class files. Native libraries, file paths, and other platform dependencies may still affect a whole application.

Comparing JDK, JRE, and JVM

Candidates frequently confuse the three core acronyms of the Java SE 8 platform. Each forms a concentric layer around the execution engine:

ComponentFull NameContainsPrimary PurposeIncludes javac?
JVMJava Virtual MachineClassloader, bytecode verifier, execution engine (may use interpretation or JIT compilation), garbage collectorExecutes .class bytecode and manages runtime memoryNo
JREJava Runtime EnvironmentJVM + standard runtime libraries (including java.lang and java.util) + runtime configEnd-user environment to run compiled Java programsNo
JDKJava Development KitJRE + development tools (javac, jar, javadoc, jdb)Developer environment to write, compile, debug, and run Java programsYes

In short: JVM⊂JRE⊂JDK\text{JVM} \subset \text{JRE} \subset \text{JDK}. An end user who only runs existing Java applications needs a JRE; a developer writing and compiling .java files needs a JDK.

Object Orientation & Encapsulation

Java is an object-oriented language built around classes (blueprints) and objects (runtime instances holding state and behavior). Four pillars shape Java design:

  • Encapsulation: Hiding internal object state (private fields) behind controlled public methods (getters, setters, or domain operations). Encapsulation prevents callers from putting an object into an invalid state—for example, setting balance = -500 directly—and allows internal representation changes without breaking callers.
  • Inheritance: Allowing a subclass to reuse and specialize a superclass (extends), sharing common contracts across related types.
  • Polymorphism: Allowing a single supertype or interface reference to invoke overridden behavior dynamically based on the actual runtime object.
  • Abstraction: Exposing essential operations (via abstract classes and interface contracts) while hiding implementation details.
public class Thermostat {
    private int targetTemp = 72; // encapsulated state

    public int getTargetTemp() {
        return targetTemp;
    }

    public void setTargetTemp(int temp) {
        if (temp >= 50 && temp <= 90) { // enforces valid invariant
            this.targetTemp = temp;
        }
    }
}

Note that Java is primarily object-oriented rather than "purely" object-oriented because it retains eight built-in primitive types (boolean, byte, short, char, int, long, float, double) alongside its reference types.

Comparing Key Language & Runtime Features

FeatureHow Java Implements ItExam Contrast / Trap
Strong Static TypingA variable has a compile-time type checked by javac. Some types are inferred, such as for implicitly typed lambda parameters.Assigning "abc" to an int variable fails at compile time, not runtime
Automatic Memory ManagementObjects are allocated on the heap; the Garbage Collector (GC) reclaims unreachable objectsNo manual free()/delete; System.gc() only suggests collection and never guarantees timing
Robustness & SafetyNo raw pointer arithmetic; automatic array bounds checking (ArrayIndexOutOfBoundsException); checked/unchecked exceptionsA Java array read outside its valid bounds throws instead of reading neighboring storage
SecurityBytecode verifier validates .class stack/type integrity before execution; ClassLoader isolates namespacesVerification checks class-file constraints, including correct operand types. Running untrusted code also requires appropriate controls.
Architecture NeutralityPrimitive widths are fixed by the JLS (int is always 32-bit, long is always 64-bit)Unlike C/C++, primitive sizes never shift across 32-bit vs. 64-bit operating systems
MultithreadingBuilt-in concurrency primitives (Thread, Runnable, synchronized)Multiple threads share heap memory and coordinate execution natively

Compile-Time Safety vs. Runtime Verification

Seeing how these guarantees divide between javac and the JVM helps answer architecture questions accurately:

public class SafetyTrace {
    public static void main(String[] args) {
        // int count = "ten";        // Compile-time error: strong static typing
        int[] scores = {90, 85};
        // System.out.println(scores[2]); // Compiles, throws ArrayIndexOutOfBoundsException

        String msg = new String("Ready");
        msg = null;                  // Original "Ready" object becomes eligible for GC
        System.gc();                 // Non-binding hint only; JVM decides when/if GC runs
        System.out.println(scores.length);
    }
}

Before SafetyTrace.class even starts executing main, the JVM's classloader loads the bytecode and the bytecode verifier checks structural and static constraints such as operand-stack type consistency. Linking also applies access checks when resolving symbolic references. During execution, strong static typing has already prevented incompatible variable assignments, while runtime bounds checks ensure out-of-range array access fails cleanly with an exception instead of corrupting adjacent memory.

Note

A common misconception is that Java guarantees zero memory leaks because of garbage collection. Garbage collection manages unreachable objects. An application can still retain memory unintentionally if it keeps reachable references (for example, in a static List) to objects it no longer needs.

Loading diagram...
Java Compilation & Write Once, Run Anywhere Architecture
Test Your Knowledge

Which statement accurately compares the JDK, JRE, and JVM in Java SE 8?

A

The JRE includes javac and javadoc so developers can compile .java source files

B

The JVM is platform-independent, whereas .class bytecode files depend on the host OS

C

The JRE is a superset of the JDK that adds debugging and packaging tools

D

The JDK contains the JRE and development tools such as javac, while the JRE contains the JVM and core runtime libraries

Test Your Knowledge

A class declares private double balance; and exposes public void deposit(double amount) that rejects negative amounts. Which Java feature does this design primarily demonstrate?

A

Platform independence

B

Encapsulation

C

Automatic garbage collection

D

Dynamic polymorphism

Test Your Knowledge

Which statement about Java's robustness and memory management features is TRUE?

A

Calling System.gc() forces the JVM to immediately reclaim all unreferenced objects before the next line executes

B

The size of a Java int depends on whether the host JVM is 32-bit or 64-bit

C

Java enforces compile-time static type checking, performs runtime array bounds checking, and prohibits raw pointer arithmetic

D

Because Java uses automatic garbage collection, it is impossible for an application to exhaust heap memory

Sections you finish are checked off in the contents.