Part 1: Core Concepts (2 Marks)
- Write Once, Run Anywhere (WORA): Java’s foundational philosophy where source code compiles into platform-independent intermediate Bytecode (
.class), executed on any operating system hosting an architecture-specific JVM. - JVM vs. JRE vs. JDK: JDK (Java Development Kit) contains compiler (
javac) and tools; JRE (Java Runtime Environment) provides class libraries and JVM; JVM (Java Virtual Machine) is the abstract execution engine executing Bytecode. - Just-In-Time (JIT) Compiler: A runtime JVM subsystem that translates frequently executed Bytecode sequences (hotspots) directly into native CPU machine instructions, dramatically boosting execution performance.
- Garbage Collection (GC): An autonomous background daemon thread in the JVM that reclaims heap memory occupied by unreferenced objects, eliminating manual memory deallocation bugs.
Part 2: Structural Frameworks (10 Marks)
Complete Java Architecture Pipeline (Source to Native Execution)
- Developer Source: Program.java
- (javac compiler)
- Platform-Independent Bytecode: Program.class
- ================ JVM BOUNDARY ================
- ClassLoader Subsystem: Loading, Linking, Initialization
- JVM Runtime Memory Areas
- Method Area | Heap (Objects) | JVM Stack (Frames) | PC Registers | Native Stack
- Execution Engine
- | Bytecode Interpreter <---> JIT Compiler (HotSpot) |
- | (C1 / C2 Compilers) |
- Native Machine Code Executed by Host OS (Windows/Linux/macOS)
Part 3: Distinction Tables
| Basis of Comparison | Java Development Kit (JDK) | Java Runtime Environment (JRE) |
|---|---|---|
| Primary Audience | Software developers and engineers | End-users executing pre-compiled applications |
| Tooling Included | Compiler (javac), debugger (jdb), archiver (jar) |
JVM, core standard class libraries, runtime loaders |
| Development Role | Required to compile and build .java files |
Capable only of executing existing .class files |
| Physical Scope | Superset of JRE ( |
Subset of JDK ( |
Part 4: Worked Problems & Exam Traps
Canonical Java Program Archetype
public class WelcomeBITM {
// Execution entry point
public static void main(String[] args) {
System.out.println("Welcome to BITM Tribhuvan University!");
for (int i = 0; i < args.length; i++) {
System.out.printf("Arg[%d] = %s\n", i, args[i]);
}
}
}
Execution workflow:
javac WelcomeBITM.javaGenerates WelcomeBITM.class.java WelcomeBITM Nepal ITExecutes JVM, outputs arguments.
TU Exam Trap: If a public class is declared
public class WelcomeBITM, the source filename MUST exactly match:WelcomeBITM.java(including strict case sensitivity). A filename mismatch triggers an immediate compilation failure.