Core Java Mastery 2026 – Phase 1 Notes
Status: Foundations Complete
Topics Covered: JVM Architecture, Memory Management, Data Types, Casting, Operators,
and Control Flow.
Part 1: The Machine & The Memory
1. The Java Trinity (Restaurant Analogy)
JDK (Java Development Kit): The Chef’s Kitchen. Contains tools like the compiler that
converts source code into bytecode.
JRE (Java Runtime Environment): The Dining Room. Provides libraries and runtime files
required to run Java programs.
JVM (Java Virtual Machine): The Universal Translator. Converts bytecode into machine-
specific instructions on any OS.
2. Memory Management: Stack vs Heap
Stack (Fast Countertop):
- Stores primitive variables and method calls
- Very fast and memory is cleared when method execution ends
Heap (Big Pantry):
- Stores objects and Strings
- Memory is managed by Garbage Collector
- Unused objects are automatically removed
Part 2: Primitive Data Types
Java is statically typed; every variable must declare a type.
Family Type Size Range / Notes
Integer byte 8-bit -128 to 127
Integer short 16-bit -32,768 to 32,767
Integer int 32-bit Default whole
number
Integer long 64-bit Suffix L required
Decimal float 32-bit Suffix f required
Decimal double 64-bit Default decimal
Other boolean 1-bit true / false
Other char 16-bit Single character
Part 3: Non-Primitive Types
String is a special object used to store text. Strings are stored in the Heap inside the String
Constant Pool for optimization.
Part 4: Type Casting & Operators
1. Type Casting
Widening Casting (Automatic): Small data type to large data type (e.g., int to double). No
data loss.
Narrowing Casting (Manual): Large data type to small data type (e.g., (int) 9.78 → 9). Data
loss possible.
2. Operators
Arithmetic Operators: +, -, *, /, %
Comparison Operators: ==, !=, >, <
Logical Operators: &&, ||, !
Part 5: Control Flow
1. Decision Making
If-Else: Used for conditional branching.
Switch: Used for menu-driven logic. Modern Java supports arrow (->) syntax.
2. Code Example
public class FoundationSummary {
public static void main(String[] args) {
int age = 25;
double price = 19.99;
char grade = 'A';
int roundedPrice = (int) price;
if (age >= 18 && grade == 'A') {
[Link]("Enrolled as Adult Student");
} else {
[Link]("Check Requirements");
}
String result = switch (grade) {
case 'A', 'B' -> "Excellent";
case 'C' -> "Passing";
default -> "Fail";
};
[Link]("Status: " + result);
}
}