Kyūkei Master Hub
SCS2108 | Phase Study Card
👁️ -- opens | 0%

Phase 3: JVM Architecture & Java Modifiers

Examiners often ask: "Explain how Java achieves Write Once, Run Anywhere (WORA)". Master JVM execution mechanics and access modifier visibility rules.

1. JVM Execution Engine (WORA Mechanics)

Java code undergoes a 2-step compilation/interpretation process:

[Source Code (.java)] ──(javac compiler)──► [Bytecode (.class)] ──(JVM)──► [Native Machine Code]

JVM Memory Structure:

2. Access Modifiers Truth Table

Java has 4 access levels governing visibility across packages and subclasses:

Modifier Same Class Same Package Subclass (Diff Package) World (Everywhere)
private ✅ Yes ❌ No ❌ No ❌ No
default (package-private) ✅ Yes ✅ Yes ❌ No ❌ No
protected ✅ Yes ✅ Yes ✅ Yes (via inheritance) ❌ No
public ✅ Yes ✅ Yes ✅ Yes ✅ Yes
💡 Examiner Distinction Tip
Notice that protected allows access to subclasses in different packages, but ONLY through inheritance (not via instance reference of parent in a different package).

3. Non-Access Modifiers (static & final)

A. The static Keyword

B. The final Keyword

⚡ Quick Self-Test

Q: What happens if you try to override a method declared as public final void compute() in a subclass?

Answer: Compile-Time Error.
The final keyword explicitly forbids method overriding in any subclass.