Java NotesRohit’s interview study guide

Interview study guide

Modern Java, from a Node.js point of view.

Java 25 and Spring Boot 4, explained next to the Node.js and TypeScript you already know. Every example on these pages was run with Java 25, and the output shown is what it printed.

Chapters
18
Topics
141
Code samples
778
Added beyond the doc
141
01How Java RunsWhat changed since Java 6, how source code becomes bytecode and runs on the JVM, the ways to run a program today, and how packages and the classpath compare with Node modules. Every example was run with Java 25 (Eclipse Temurin 25.0.5.1).6 topics02Types, Variables and StringsStatic types and var, the eight primitives and their wrapper classes, how Java numbers overflow, divide and round (and why money is BigDecimal), why strings are compared with equals, the operators and control flow that differ from JavaScript, and arrays. Every example was run with Java 25 (Eclipse Temurin 25.0.5.1).7 topics03Classes, Objects, Records and EnumsHow Java classes compare with TypeScript classes, access levels including package-private, static and final, inheritance and the difference between overloading and overriding, interfaces and nominal typing, the equals/hashCode contract, records, enums, sealed types, and the four kinds of nested class. Every example was run with Java 25 (Eclipse Temurin 25.0.5.1).10 topics04GenericsGeneric classes and methods compared with TypeScript generics, type erasure and what it forbids, bounded types and the ? extends / ? super wildcards (PECS), and the traps: no primitives, raw types, heap pollution and covariant arrays. Every example was run with Java 25 (Eclipse Temurin 25.0.5.1).5 topics05Null, Optional and Pattern MatchingWhy null is still Java's most common crash and how modern Java helps (helpful NPE messages, Optional), then pattern matching: instanceof that binds, switch over types and records, and sealed hierarchies the compiler checks for you, Java's answer to TypeScript's discriminated unions. Every example was run with Java 25.6 topics06ExceptionsJava's exception hierarchy, checked versus unchecked exceptions, try/catch/finally, try-with-resources and suppressed exceptions, chaining and reading a stack trace, and the habits interviewers look for. Every example was run with Java 25 (Eclipse Temurin 25.0.5.1).6 topics07CollectionsLists, sets, maps and queues: which implementation to pick and what it costs, how HashMap really works, ordered and sorted maps, immutable collections, sequenced collections (Java 21), sorting with Comparator, and why iterating can throw ConcurrentModificationException. Every example was run with Java 25 (Eclipse Temurin 25.0.5.1); the JavaScript comparisons were run with Node 26.9 topics08Lambdas and StreamsLambdas and the functional interfaces they implement, method references, streams compared with JavaScript's array methods, collectors, flatMap and primitive streams, when parallel streams help, and stream gatherers (Java 24). Every example was run with Java 25 (Eclipse Temurin 25.0.5.1); the JavaScript comparisons were run with Node 26.8 topics09Concurrency and Virtual ThreadsHow Java runs many things at once with real threads that share memory, why that's different from Node's single event loop, the bugs it brings (races, visibility, deadlocks) and the tools that fix them: synchronized, atomics, locks, thread pools, CompletableFuture, virtual threads (Java 21), scoped values and structured concurrency. Every example was run with Java 25 (Eclipse Temurin 25.0.5.1) on an 18-core Mac; the JavaScript comparison was run with Node 26.10 topics10The JVM: Memory, GC and PerformanceWhat the JVM does with your program while it runs: where objects and stack frames live, how the garbage collector frees memory (and how that compares with V8), why Java code gets faster after warming up, how classes are loaded, how memory still leaks, the tools for looking inside a running JVM, and how to make it start fast and fit in a container. Every example was run with Java 25 (Eclipse Temurin 25.0.5.1) on an 18-core Mac with 64 GB of memory.8 topics11Maven, Gradle and Project StructureHow a Java project is built: Maven's pom.xml compared with package.json, dependencies and their scopes, the build lifecycle, Gradle, the Spring Boot starter project every later chapter uses, and what's inside the JAR you deploy. Every example was run with Java 25, Maven 3.10.1 and Gradle 9.9.2 through their wrappers.7 topics12Spring Core: Dependency Injection and Spring BootWhat Spring actually does: it creates your objects and wires them together (dependency injection), and Spring Boot configures the infrastructure for you from what's on the classpath. Beans, component scanning, constructor injection, scopes, configuration and profiles, auto-configuration, the proxies behind @Transactional, and what happens when an app starts. Every example was run with Spring Boot 4.2.0 on Java 25.9 topics13REST APIs with Spring MVCBuilding a JSON API the Spring way, next to the Express you know: controllers and mappings, path variables, query parameters, request bodies and status codes, records as DTOs with Jackson 3, validation, errors as RFC 9457 problem details, calling other APIs with RestClient and HTTP interface clients, Boot 4's built-in API versioning, filters and interceptors, and virtual threads. Every example was run with Spring Boot 4.2.0 on Java 25, and every response shown is what curl really got.10 topics14Data Access with Spring Data JPAHow a Spring Boot service talks to a relational database: JPA and Hibernate underneath, Spring Data repositories on top, the N+1 problem and lazy loading shown in the real SQL log, what @Transactional really rolls back, schema migrations with Flyway, and plain SQL with JdbcClient. Every example was run with Spring Boot 4.2.0 (Hibernate ORM 7.4.15, Spring Data JPA 4.2) on Java 25, against the H2 in-memory database that the starter includes.9 topics15Testing Java and Spring BootJUnit, AssertJ and Mockito compared with the Jest you know, then Spring Boot's test support: the full context, test slices, @MockitoBean, controller tests with MockMvcTester and RestTestClient, and a real PostgreSQL in Docker with Testcontainers. Every example was run with Spring Boot 4.2.0 on Java 25 (JUnit Jupiter 6.1.3, AssertJ 3.27.7, Mockito 5.24.0, Testcontainers 2.0.5).8 topics16Security and ProductionWhat it takes to run a Spring Boot service for real: Spring Security's filter chain, securing an API with HTTP Basic and JWT bearer tokens, password storage, CORS and CSRF, Actuator health and metrics, logging, observability, and packaging the app into a container image. Every example was run with Spring Boot 4.2.0 (Spring Security 7.2) on Java 25.9 topics17Microservices with SpringThe Spring side of a microservices architecture: what each Spring Cloud project is for, keeping one slow service from taking down the rest (timeouts, retries, circuit breakers), events with Kafka, keeping data consistent across services with the outbox pattern, and caching. Every example was run with Spring Boot 4.2.0 on Java 25; Kafka ran as an embedded broker inside the test.6 topics18Interview QuestionsThe Java and Spring Boot questions senior full stack and backend interviews ask, with answers you can say out loud in a minute or two: the language, collections and generics, concurrency, the JVM, Spring, JPA, testing and production, and the questions about coming to Java from Node.js. The "what does this print?" cards were run with Java 25.8 topics

Added marks topics that weren’t in my original doc. Tick Learned on a topic to track what you’ve revised.

Sync progress across devices

Type the same private phrase on your Mac and your phone, and your Learned ticks follow you between them — on every study site.

The phrase never leaves this device: only a fingerprint of it is sent, and the server stores a fingerprint of that. Anyone who knows the phrase could see or change your ticks, so pick something you don’t use elsewhere.

Sync is on in this browser.

Sync ID

This ID must be the same on every device. If another device shows a different one, its phrase is different (capital letters count): tap “Turn off here” on it and type the phrase again exactly.