Chapter-Wise Revision Notes

Java Quick Revision Notes

Module 1: Java Introduction & Environment Setup

Introduction to Java Programming

Discover Java's history, core design philosophy, Write Once Run Anywhere (WORA), editions (SE, EE, ME), and how Java compares with C, C++, and Python.

  • **Platform Independent (Write Once, Run Anywhere)**: Bytecode compiled on macOS runs identically on Linux Docker containers or Windows servers.
  • **Object-Oriented**: Models software around classes and objects, promoting encapsulation, modularity, and code reuse.
  • **Automatic Memory Management**: The JVM's Garbage Collector (G1, ZGC, Shenandoah) reclaims unreachable objects on the Heap automatically, eliminating manual `free()` bugs.
  • **Strongly & Statically Typed**: Every variable and expression has a compile-time type, catching whole classes of bugs before deployment.
Module 1: Java Introduction & Environment Setup

JDK, JRE, JVM & Internal Working of Java

Master the exact differences between JDK, JRE, and JVM, plus how ClassLoader, Bytecode Verifier, Interpreter, and JIT Compiler execute your program.

  • **Bootstrap ClassLoader**: Loads core JDK classes (`java.base`).
  • **Platform ClassLoader**: Loads standard extension modules.
  • **Application ClassLoader**: Loads your application classes from the classpath/modulepath.
  • **Verify**: Ensures bytecode does not forge pointers, overflow operand stacks, or violate access modifiers.
Module 1: Java Introduction & Environment Setup

Java Installation, PATH Setup & Command-Line Execution

Install JDK on Windows, Linux, and macOS, configure JAVA_HOME and PATH, set up IntelliJ IDEA / Eclipse / VS Code, and pass command-line arguments.

  • **Windows (PowerShell / System Environment Variables)**: * Set `JAVA_HOME` = `C:\Program Files\Java\jdk-21`
  • **Linux / macOS (`~/.bashrc` or `~/.zshrc`)**: ```bash
  • **IntelliJ IDEA**: Industry-standard Java IDE with deep refactoring, Maven/Gradle integration, and visual debugger.
  • **VS Code**: Lightweight editor with Microsoft's "Extension Pack for Java".
Module 2: Java Fundamentals, Variables & Data Types

Java Syntax, Keywords, Identifiers & Comments

Learn Java's case-sensitive syntax rules, reserved keywords, valid identifier rules, Unicode system, and single/multi-line/Javadoc comments.

  • Write syntactically valid Java classes, methods, and blocks.
  • Apply legal identifier rules and avoid Java's reserved keywords.
  • Document code cleanly with single-line, multi-line, and Javadoc comments.
  • Understand how Java's 16-bit Unicode system supports international characters.
Module 2: Java Fundamentals, Variables & Data Types

Java Variables & Scope (Local, Instance, Static)

Understand how to declare variables, constants with final, and the lifecycle of Local, Instance, and Static variables.

  • a variable is declared determines its **scope** (where it can be accessed), **lifetime** (when it is created and destroyed), **memory region** (Stack vs Heap vs Metaspace), and **default value**.
  • Declare, initialize, and update variables and `final` constants.
  • Distinguish between **Local**, **Instance**, and **Static (Class)** variables in memory and lifecycle.
  • | Inside a method, constructor, or block | Thread Stack | **None** (compile error if read before init) | Until the method/block exits |
Module 2: Java Fundamentals, Variables & Data Types

Java Data Types & Type Casting

Explore all 8 primitive data types (byte, short, int, long, float, double, char, boolean), non-primitive types, literals, and implicit/explicit type casting.

  • **Widening (Implicit)**: Converting a smaller type to a larger type happens automatically with no data loss: `byte -> short -> int -> long -> float -> double` (and `char -> int`).
  • **Narrowing (Explicit)**: Converting a larger type to a smaller type requires an explicit cast `(targetType)` and may truncate decimals or overflow!
  • **Numeric Promotion in Expressions**: Arithmetic on `byte`, `short`, or `char` automatically promotes operands to `int`. That is why `byte a = 10, b = 20; byte c = (byte)(a + b);` requires a cast.
Module 2: Java Fundamentals, Variables & Data Types

Console Input & Output (Scanner & BufferedReader)

Read user input cleanly using Scanner and BufferedReader, format console output with printf, and avoid the classic nextLine() buffer pitfall.

  • | Built-in `nextInt()`, `nextDouble()`, `nextLine()` | Only `readLine()` (parse with `Integer.parseInt`) |
  • | 1 KB | 8 KB |
  • | Slower (uses regex tokenization) | Much faster (ideal for large inputs) |
  • | No | Throws `IOException` |
Module 3: Java Operators

Arithmetic, Unary, Relational & Logical Operators

Understand all core Java operators, short-circuit evaluation with && and ||, and prefix vs postfix increment/decrement.

  • **Unary (`+`, `-`, `++`, `--`, `!`)**: `++x` increments first and returns the new value; `x++` returns the original value and then increments.
  • **Relational (`==`, `!=`, `>`, `<`, `>=`, `<=`)**: Always evaluate to `boolean`.
  • **Logical (`&&`, `||`, `!`)**: Use **short-circuit evaluation**: in `a != null && a.length() > 0`, if `a != null` is `false`, Java skips evaluating the right-hand side completely, preventing a `NullPointerException`.
Module 3: Java Operators

Bitwise, Shift, Ternary & Operator Precedence

Use bitwise AND/OR/XOR, signed and unsigned shifts (<<, >>, >>>), the ternary operator (?:), and operator precedence rules.

  • **`&` (Bitwise AND)**: `1` only if both bits are `1`. Useful for bitmasking (`(num & 1) == 0` checks even numbers).
  • **`|` (Bitwise OR)**: `1` if either bit is `1`. Useful for combining permission flags.
  • **`^` (Bitwise XOR)**: `1` if bits differ. Property: `a ^ a == 0` and `a ^ 0 == a`.
  • **`~` (Bitwise Complement)**: Flips every bit (`~n == -(n + 1)`).
Module 4: Control Flow & Loops

Conditional Statements (if, else-if, Switch & Modern Switch)

Control program branching with if-else ladders, classic switch-case, and modern Java 14+ switch expressions with arrow syntax.

  • Build decision trees using `if`, `if-else`, nested `if`, and `else-if` ladders.
  • Understand classic `switch` fall-through behavior and why `break` is required.
  • Use modern Java 14+ **Switch Expressions** with arrow syntax (`->`) and `yield`.
  • solve this:
Module 4: Control Flow & Loops

Loops (for, enhanced for, while, do-while) & Jump Statements

Iterate efficiently with for, for-each, while, and do-while loops, and control iteration with break, continue, and return.

  • **`break`**: Exits the innermost loop or `switch`. With a label (`outer: for (...)` + `break outer;`), it can exit nested loops cleanly.
  • **`continue`**: Skips the rest of the current iteration and jumps to the loop condition/update.
  • **`return`**: Exits the entire enclosing method immediately.
Module 5: Java Arrays

One-Dimensional, 2D & Jagged Arrays

Declare, initialize, and traverse 1D, 2D, and jagged arrays, and understand fixed-size heap allocation.

  • **Multidimensional & Jagged Arrays**: A 2D array `int[][]` is actually an array of references to 1D `int[]` arrays on the Heap. Therefore, each row can have a **different length** (a **Jagged Array**).
Module 5: Java Arrays

Arrays Utility Class, Reversal & Interview Problems

Solve classic array problems including two-pointer reversal, binary search, and finding maximum/second-largest elements.

  • `Arrays.sort(arr)` / `Arrays.parallelSort(arr)`: Sorts arrays in-place.
  • `Arrays.binarySearch(arr, key)`: O(log n) search (the array **must** be sorted first, otherwise the result is undefined!).
  • `Arrays.copyOf(arr, newLength)` & `Arrays.copyOfRange(arr, from, to)`: Fast native array copying.
  • `Arrays.equals(a, b)`: Deeply compares contents (whereas `a.equals(b)` only compares references!).
Module 6: Java Strings & StringBuilder

Java Strings, Immutability & String Pool

Understand why Java Strings are immutable, how the String Constant Pool saves memory, and why .equals() must be used instead of ==.

  • `==` compares **memory addresses** (whether both variables point to the exact same object).
  • `.equals()` compares **character content**. Always use `.equals()` (or `.equalsIgnoreCase()`) to compare string values!
  • Calling `s.toUpperCase()` or `s.trim()` without assigning the return value—`String` methods always return a *new* `String`.
Module 6: Java Strings & StringBuilder

StringBuilder, StringBuffer & Immutable Classes

Compare String, StringBuilder, and StringBuffer for performance and thread safety, and learn how to design your own immutable Java class.

  • time and flooding Garbage Collection. Use `StringBuilder` for mutable string assembly in **O(n)** time.
  • | Immutable | Mutable | Mutable |
  • | Yes (immutable) | No (single-thread) | Yes (`synchronized` methods) |
  • | O(n^2) in loops | **Fastest (O(n))** | Slower due to lock overhead |
Module 7: Object-Oriented Programming (OOP)

Classes, Objects, Fields & Methods

Design classes and instantiate objects in Java, define instance fields and methods, and understand parameter passing and return types.

  • (blueprints) and **objects** (runtime instances on the Heap). A class defines *state* (fields) and *behavior* (methods).
  • an object does while hiding *how* it does it.
  • stored in local variable `c` on the Stack.
  • is copied—so a method can mutate the object's fields, but reassigning the parameter variable does not affect the caller's reference.
Module 7: Object-Oriented Programming (OOP)

Constructors, this Keyword & static Members

Use default and parameterized constructors, constructor chaining with this(), static variables, static methods, and static initialization blocks.

  • **Constructor Chaining (`this(...)`)**: Calls another constructor in the same class and **must be the first statement**.
  • **Static Fields**: Shared across all instances of the class (one copy per class).
  • **Static Methods**: Belong to the class, called via `ClassName.method()`, and cannot reference `this`, `super`, or instance fields directly.
  • **Static Initialization Blocks**: `static { ... }` executes once when the class is first loaded by the JVM—ideal for one-time lookup table setup.
Module 8: Inheritance & Composition

Java Inheritance, extends, super & Composition

Reuse and specialize classes using single, multilevel, and hierarchical inheritance, invoke parent constructors with super(), and prefer composition when appropriate.

  • **Single**: `B extends A`
  • **Multilevel**: `C extends B extends A`
  • **Hierarchical**: `B extends A` and `C extends A`
  • **Multiple Inheritance**: Disallowed for classes (prevents the **Diamond Problem**, where two parent classes define conflicting implementations of the same method), but supported for **interfaces** (`class X implements A, B`).
Module 9: Polymorphism

Polymorphism: Overloading, Overriding & Dynamic Dispatch

Understand static vs dynamic binding, method overloading vs overriding, upcasting, downcasting, and safe instanceof checks.

  • **Upcasting**: `Payment p = new UpiPayment();` (automatic, always safe).
  • **Downcasting**: Always guard with `instanceof` (Java 16+ supports `if (p instanceof UpiPayment u)`) to avoid `ClassCastException`.
Module 10: Abstraction & Interfaces

Abstract Classes, Interfaces & Functional Interfaces

Hide implementation complexity with abstract classes and interfaces, implement multiple interfaces, and use Java 8+ default/static interface methods.

  • **`default` methods (Java 8+)**: Allow adding new methods to interfaces without breaking existing implementations.
  • **`@FunctionalInterface`**: Marks an interface with **exactly one abstract method** so it can be implemented concisely via a Lambda expression or Method Reference.
Module 11: Encapsulation & Packages

Encapsulation, Access Modifiers & Packages

Master private fields, validated getters/setters, all 4 Java access levels, user-defined packages, and import statements.

  • (no keyword) | Yes | Yes | No | No |
  • **Packages** (`package com.codezov.service;`) mirror directory structure, prevent class name collisions, and enable package-private encapsulation.
  • **Static Imports** (`import static java.lang.Math.PI;`) let you reference static constants/methods without qualifying the class name (use sparingly to keep code readable).
Module 12: Advanced Java Object Concepts

Object Class, Wrapper Classes, Records & Sealed Classes

Override toString, equals, and hashCode properly, use Wrapper classes & autoboxing, and leverage modern Java Records and Sealed classes.

  • **`toString()`**: Returns a human-readable string representation (default is `ClassName@hexHash`). Always override it on domain models for clear logs and debugger inspection.
  • **`equals(Object o)`**: Must be reflexive, symmetric, transitive, consistent, and return `false` for `null`.
  • **`hashCode()`**: Must return the **same integer** for any two objects where `a.equals(b)` is `true`. If you override `equals()` without overriding `hashCode()`, two equal objects may land in different `HashMap` buckets and never be found!
  • **Autoboxing**: Automatic `int -> Integer` conversion (`Integer.valueOf(x)`).
Module 13: Java Math & Random

Math Class, Random & SecureRandom

Perform mathematical operations with Math.pow, Math.sqrt, Math.abs, rounding methods, and generate pseudo-random and cryptographically secure numbers.

  • **`java.util.Random`**: Uses a 48-bit seed and a Linear Congruential Generator (LCG). It is fast and deterministic (given the same seed, it reproduces the exact same sequence—great for unit tests and simulations), but **predictable**. An attacker observing a few outputs can deduce the seed and predict future numbers.
  • **`java.security.SecureRandom`**: Gathers entropy from the OS kernel (`/dev/urandom` or Windows CryptGenRandom). Always use `SecureRandom` for OTPs, password reset tokens, API keys, and cryptographic salts.
Module 14: Exception Handling

Exceptions, Try-Catch-Finally & Try-With-Resources

Handle runtime failures gracefully using try-catch, multi-catch, try-with-resources (AutoCloseable), custom exceptions, and best practices.

  • **`Error`**: Severe JVM/system failures (`OutOfMemoryError`, `StackOverflowError`, `NoClassDefFoundError`). Applications generally cannot recover from these and should not catch them.
  • **`Exception`**: * **Checked Exceptions** (`IOException`, `SQLException`, `ClassNotFoundException`): Verified at compile time; the caller **must** either handle them with `try-catch` or declare `throws` in the method signature.
Module 15: Java Regular Expressions

Pattern, Matcher & Input Validation with Regex

Use java.util.regex.Pattern and Matcher for pattern matching, quantifiers, groups, and email/phone validation.

  • **`Pattern.compile(regex)`**: Compiles the regex string into an internal finite-state automaton. **Always** compile patterns once into a `static final` constant—calling `String.matches(regex)` inside a loop recompiles the regex on every iteration!
  • **`Matcher`**: Stateful matching engine created by `pattern.matcher(input)`:
  • **Character Classes**: `\d` (digit `[0-9]`), `\w` (word char `[A-Za-z0-9_]`), `\s` (whitespace), `.` (any char except newline).
  • **Quantifiers**: `*` (0 or more), `+` (1 or more), `?` (0 or 1), `{n,m}` (between n and m).
Module 16: Java Collections Framework

List, ArrayList, LinkedList & Queue/Deque

Master the Java Collections hierarchy, dynamic resizing in ArrayList, doubly-linked nodes in LinkedList, and ArrayDeque/PriorityQueue.

  • **`ArrayDeque`**: Resizable circular array implementing both Queue (FIFO) and Stack (LIFO). Faster than legacy `Stack` (which is synchronized) and `LinkedList`.
  • **`PriorityQueue`**: Binary min-heap supporting O(log n) `offer()` / `poll()` and O(1) `peek()`—ideal for top-K problems and task scheduling.
Module 16: Java Collections Framework

Set, HashMap Internals, TreeMap & Comparable vs Comparator

Understand HashSet, LinkedHashSet, TreeSet, HashMap bucket/hashing internals (Java 8 treeification), and Comparable vs Comparator.

  • **`HashSet`**: Unordered, O(1) average lookup/insert, backed internally by a `HashMap` where each element is a key mapped to a dummy `PRESENT` object.
  • **`LinkedHashSet`**: Preserves insertion order using a doubly-linked list across entries.
  • **`TreeSet`**: Backed by a Red-Black self-balancing BST; keeps elements sorted in O(log n) time and disallows `null`.
Module 17: Java Generics

Generic Classes, Methods, Wildcards & Type Erasure

Achieve compile-time type safety with generics, PECS wildcards (? extends / ? super), and understand JVM type erasure.

  • **Upper-Bounded (`? extends T`)**: Use when the collection **produces** `T` values for you to read (`List<? extends Number>`). You cannot add elements (except `null`) because the exact subtype is unknown.
  • **Lower-Bounded (`? super T`)**: Use when the collection **consumes** `T` values you write into it (`List<? super Integer>`).
  • **Unbounded (`?`)**: Use when you only need `Object` methods or `List.size()`.
Module 18: Java I/O Streams

Byte Streams, Character Streams & Buffered I/O

Understand java.io byte vs character streams, buffering for performance, and closing streams automatically with try-with-resources.

  • **Byte Streams (`InputStream`, `OutputStream`)**: Read and write raw 8-bit bytes (`0–255`). Always use these for binary files (images, PDFs, ZIP archives, audio).
  • **Character Streams (`Reader`, `Writer`)**: Read and write 16-bit Unicode characters and handle character encoding/decoding automatically. Always specify `StandardCharsets.UTF_8` explicitly instead of relying on the OS default charset.
Module 19: File Handling & NIO.2

File Handling with File and Modern Files / Path (NIO.2)

Compare legacy java.io.File with modern java.nio.file.Path and Files APIs for safe, clean file and directory operations.

  • (missing file vs permission denied vs non-empty directory), and it lacks symbolic-link and atomic-move support.
  • (`java.nio.file.Path` and `Files`, introduced in Java 7 and enhanced in Java 11) fixes all of this:
  • `Path.of("dir", "sub", "file.txt")`: OS-independent path construction.
  • `Files.readString(path)` / `Files.writeString(path, text)` (Java 11+): Clean one-line UTF-8 file I/O.
Module 20: Serialization

Object Serialization, transient & serialVersionUID

Understand Java serialization, excluding sensitive fields with transient, and versioning classes with serialVersionUID.

  • **`Serializable`**: A marker interface (no methods). If a `Serializable` class holds a reference to a non-serializable field, serialization throws `NotSerializableException` unless that field is marked `transient`.
  • **`serialVersionUID`**: Always declare `private static final long serialVersionUID = 1L;`. If omitted, the JVM computes a hash from class structure—meaning adding a single method breaks deserialization of previously saved objects with `InvalidClassException`.
  • **`transient` & `static`**: Both `transient` fields and `static` fields are skipped during serialization.
  • **Security Warning**: Never deserialize untrusted byte streams from external users (deserialization gadget attacks); prefer JSON (Jackson/Gson) or Protobuf for APIs.
Module 21: Multithreading & Concurrency

Threads, Lifecycle, ExecutorService & CompletableFuture

Create threads using Runnable/Thread, understand thread states, avoid calling run() directly, and scale with ExecutorService and CompletableFuture.

  • is an independent OS program with its own isolated virtual address space. A **thread** is a lightweight unit of execution *inside* a process: all threads in a JVM share the **Heap** and **Metaspace**, while each thread maintains its own private **JVM Stack** and **Program Counter (PC) Register**.
  • from the *execution mechanism* lets you submit tasks to thread pools.
  • Calling `t.start()` asks the JVM to allocate a new call stack and schedule concurrent execution.
  • Calling `t.run()` directly is a common bug—it simply executes synchronously on the current thread! Calling `t.start()` twice throws `IllegalThreadStateException`.
Module 22: Java Synchronization

Race Conditions, Synchronized, Volatile & Deadlocks

Ensure thread safety using synchronized methods/blocks, ReentrantLock, AtomicInteger, volatile visibility, and deadlock prevention.

  • **`wait()`, `notify()`, `notifyAll()`**: Must be called inside a `synchronized` block on the lock object. Always call `wait()` inside a `while (!condition)` loop (not `if`) to guard against **spurious wakeups**.
  • **Deadlock Prevention**: A deadlock occurs when Thread A holds Lock 1 waiting for Lock 2 while Thread B holds Lock 2 waiting for Lock 1. Break circular wait by **always acquiring locks in a consistent global order** or using `ReentrantLock.tryLock()`.
Module 23: Java 8 & Functional Programming

Lambda Expressions, Functional Interfaces & Stream API

Write expressive, declarative pipelines with Java 8 Lambdas, Method References, Stream filter/map/reduce/collect, and null-safe Optional.

  • **`Predicate<T>`**: `T -> boolean` (`test(t)`) — filtering conditions.
  • **`Function<T, R>`**: `T -> R` (`apply(t)`) — transforming values.
  • **`Consumer<T>`**: `T -> void` (`accept(t)`) — consuming items (e.g., logging).
  • **`Supplier<T>`**: `() -> T` (`get()`) — lazy value generation.
Module 24: Java Date and Time API

Modern Date & Time (java.time)

Replace legacy Date/Calendar with immutable, thread-safe LocalDate, LocalDateTime, ZonedDateTime, Period, and DateTimeFormatter.

  • **`LocalDate`**: Date without time or timezone (e.g., birthdays, holidays).
  • **`LocalTime`**: Time of day without date.
  • **`LocalDateTime`**: Date + time without timezone.
  • **`Period` vs `Duration`**: `Period` measures calendar units (years, months, days); `Duration` measures exact time (hours, minutes, seconds, nanos).
Module 25: Enums & Annotations

Java Enums & Custom Annotations

Build rich Enums with constructors/methods and create custom runtime Annotations using @Retention and @Target.

  • **Built-in**: `@Override` (compile-time check), `@Deprecated`, `@SuppressWarnings`, `@FunctionalInterface`.
  • **Meta-Annotations**: * `@Target(ElementType.METHOD)`: Restricts where the annotation can be placed.
Module 26: Java JDBC & Database Connectivity

JDBC Architecture, PreparedStatement, CRUD & Transactions

Build secure database-driven Java applications with Connection, PreparedStatement (preventing SQL injection), ResultSet, and ACID transactions.

  • **JDBC Driver (Type 4 Pure Java)**: Translates JDBC calls into the database's native wire protocol (e.g., `mysql-connector-j`).
  • **`DriverManager` vs `DataSource`**: `DriverManager.getConnection(...)` opens a raw TCP connection per call (slow). Production servers always use a **`DataSource` connection pool** (like **HikariCP**) to reuse open connections.
  • **`PreparedStatement` vs `Statement`**: Never concatenate user input into SQL strings with `Statement`—that causes **SQL Injection**! `PreparedStatement` precompiles parameterized SQL (`?` placeholders) and binds user values safely as literal data.
  • **`ResultSet`**: Forward-only cursor over query rows (`while (rs.next())`).
Module 27: Java Networking

Networking, HttpClient & Socket Programming

Understand TCP vs UDP, inspect URLs and InetAddress, and build client-server communication with Sockets and Java 11+ HttpClient.

  • **TCP (`Socket` / `ServerSocket`)**: Connection-oriented, reliable, ordered byte stream—used by HTTP, databases, and chat servers.
  • **UDP (`DatagramSocket` / `DatagramPacket`)**: Connectionless, low-overhead packets—used by DNS, gaming, and live video streaming.
  • **`java.net.http.HttpClient` (Java 11+)**: Replaces the verbose `HttpURLConnection` with HTTP/2 multiplexing, WebSockets, and non-blocking `sendAsync()` returning `CompletableFuture<HttpResponse<T>>`.
  • **`URI` vs `URL`**: Prefer `URI` for parsing and validation (`new URL(string)` was deprecated in Java 20).
Module 28: Java Reflection API

Reflection API & Bytecode Inspection

Use Class.forName, inspect declared methods and fields dynamically, and understand how frameworks like Spring and JUnit rely on reflection.

  • **Spring**: Scans classes for `@Component`/`@Service`, inspects constructors, and injects dependencies dynamically.
  • **Hibernate / JPA**: Reads `@Entity` and `@Column` annotations to map database rows to Java objects.
  • **JUnit**: Discovers and invokes `@Test` methods automatically.
  • **Jackson**: Serializes and deserializes POJOs/Records to JSON.
Module 29: Java Internationalization (i18n)

Locale, ResourceBundle & Currency Formatting

Format currencies, numbers, and dates for global audiences using Locale and NumberFormat.

  • **`Locale`**: Represents a language + region pair (e.g., `en-IN`, `en-US`, `fr-FR`).
  • **`ResourceBundle`**: Loads locale-specific `.properties` files (`messages_en.properties`, `messages_hi.properties`) with automatic fallback to the base bundle.
  • **`NumberFormat` & `DateTimeFormatter`**: Format numbers, percentages, currencies, and dates according to regional grouping and symbols.
Module 30: JVM & Memory Management

JVM Memory Areas, Stack vs Heap & Garbage Collection

Master Heap generations (Young/Old), Thread Stacks, Metaspace, G1/ZGC Garbage Collectors, and diagnosing memory leaks.

  • **Young Generation (Eden + Survivor S0/S1)**: Fast **Minor GC** sweeps short-lived objects in milliseconds.
  • **Old (Tenured) Generation**: Objects that survive multiple Minor GCs are promoted here and collected by **Major / Mixed GC**.
  • **Modern Collectors**: **G1GC** (default since Java 9, balances throughput and pause times) and **ZGC** (Generational ZGC in Java 21 achieves sub-millisecond pauses on multi-GB/TB heaps).
Module 31: Modern Java (Java 5 to Java 25)

Version-Wise Modern Java Features (Java 5 through Java 25)

Accurately map every landmark Java feature to the exact JDK version that introduced it—from Java 5 Generics to Java 21 Virtual Threads.

  • releases every 2 years (Java 8, 11, 17, 21, 25). Knowing **which version introduced each feature** prevents compatibility bugs and is frequently tested in senior Java interviews.
  • | Generics, Annotations, Autoboxing/Unboxing, Varargs, `enum`, Static Imports, Enhanced `for-each` |
  • | Lambda Expressions, Stream API, `Optional`, Default/Static interface methods, `java.time` |
  • | Module System (JPMS), `List.of()`/`Set.of()`/`Map.of()`, Private interface methods, JShell |
Module 32: Java Security

Secure Coding, Hashing & Cryptography in Java

Protect Java applications against injection, weak randomness, and insecure data storage using MessageDigest and SecureRandom.

  • Protect Java applications against injection, weak randomness, and insecure data storage using MessageDigest and SecureRandom.
  • Practice writing and running standard examples.
  • Apply best practices and debugging techniques.
Module 33: Java Testing (JUnit & Mockito)

Unit Testing with JUnit 5 & Mockito

Structure reliable unit tests using JUnit 5 lifecycle annotations, assertions, and Mockito mocks for isolated business logic testing.

  • `@BeforeAll` / `@AfterAll`: Static setup/teardown once per test class.
  • `@BeforeEach` / `@AfterEach`: Fresh setup before/after every `@Test` method so tests never share mutable state.
  • `@ParameterizedTest` with `@CsvSource` / `@ValueSource`: Runs the same test logic across dozens of edge-case inputs cleanly.
  • Assertions: `assertEquals`, `assertNotNull`, `assertThrows(IllegalArgumentException.class, () -> ...)`, `assertAll`.
Module 34: Java Build Tools (Maven & Gradle)

Maven vs Gradle & Standard Project Structure

Understand src/main/java and src/test/java, Maven pom.xml lifecycle phases, and Gradle build.gradle scripts.

  • `src/main/java`: Application source code
  • `src/main/resources`: Config files (`application.yml`, SQL migrations, templates)
  • `src/test/java`: Unit and integration tests
  • | Declarative XML (`pom.xml`) | Groovy / Kotlin DSL (`build.gradle.kts`) |
Module 35: Java Design Patterns & SOLID Principles

SOLID Principles, Singleton, Factory, Builder & Strategy

Write clean, extensible Java architectures using SOLID principles and essential Creational, Structural, and Behavioral design patterns.

  • **S – Single Responsibility**: Every class should have one cohesive responsibility and one reason to change.
  • **O – Open/Closed**: Open for extension (via interfaces/polymorphism), closed for modification.
  • **L – Liskov Substitution**: Subtypes must be cleanly substitutable for their base types without breaking expectations.
  • **I – Interface Segregation**: Prefer small, focused interfaces over bloated "god interfaces".
Module 36: Advanced Java & Spring Boot Overview

Servlets, JSP, Sessions & Spring Boot Introduction

Understand HTTP request/response lifecycles in Servlets & JSP, session management, and how Spring Boot simplifies enterprise REST APIs.

  • **Servlet Lifecycle**: Container calls `init()` once -> `service(HttpServletRequest, HttpServletResponse)` dispatches `doGet`/`doPost` per HTTP request -> `destroy()` on shutdown.
  • **JSP**: HTML templates with embedded directives/expressions that the container compiles into Servlets.
  • **Sessions & Cookies**: HTTP is stateless; `HttpSession` stores server-side session state keyed by a `JSESSIONID` cookie, whereas modern REST APIs typically use stateless signed **JWT** tokens.
  • **IoC & Dependency Injection**: Spring's `ApplicationContext` instantiates and wires `@RestController`, `@Service`, and `@Repository` beans via constructor injection, decoupling components for easy testing.
Module 37: Java Capstone Projects

Capstone Project: Console Banking & Student Management System

Build a complete OOP-based Banking & Student Management application with encapsulated accounts, collections, exception handling, and transaction history.

  • **Domain Layer**: `BankAccount` enforces balance invariants (rejecting negative deposits and overdrafts).
  • **Service / Registry Layer**: `HashMap<String, BankAccount>` provides O(1) lookup by account ID.
  • **Error Handling**: Custom checked exceptions communicate business-rule failures cleanly to callers.