Java Tutorial
Learn Java from your first program to OOP, collections, streams, concurrency and JVM internals. Each topic has a clear explanation, working code, key points and interview questions.
30 topics · Beginner → Expert · concept, code, interview questions and a test in every topic
Beginner lessons
0/5 · 0%
- 1Java, JDK, JRE & JVMHow Java code is compiled and run anywhere.
- 2Variables, Data Types & OperatorsPrimitives, references, casting and operators.
- 3Control Flow & Loopsif/else, switch expressions, for, while and enhanced for.
- 4Arrays & StringsFixed-size arrays, immutable Strings and StringBuilder.
- 5Methods & RecursionParameters, return values, overloading and recursion.
Intermediate lessons
0/6 · 0%
- 6Classes, Objects & ConstructorsBlueprints, instances, this, static and records.
- 7OOP: Encapsulation, Inheritance, PolymorphismThe pillars of object-oriented Java.
- 8Abstract Classes & InterfacesContracts, default methods and sealed types.
- 9Exception Handlingtry/catch/finally, checked vs unchecked, custom exceptions.
- 10Collections FrameworkList, Set, Map, Queue and choosing the right one.
- 11Functions Reference: Core Utilities, Strings & MathString, Math, Arrays, Collections and wrapper-class methods you'll use every day.
Advanced lessons
0/4 · 0%
- 12Functions Reference: Collections & Stream APIList, Set and Map methods, Collections utilities and Stream pipelines with complexity notes.
- 13GenericsType-safe reusable code, bounds and wildcards.
- 14Lambdas & Stream APIFunctional style: map, filter, reduce and collectors.
- 15Multithreading BasicsThreads, synchronization, volatile and race conditions.
Expert lessons
0/3 · 0%
Interview preparation
Module — Core Technical Interview Q&A (Top Questions & Answers)
6 questions · 0 completed · 0%
Module — Core Technical Interview Q&A (Top Questions & Answers)
6 questions · 0 completed · 0%
Beginner · Fundamentals
Can a Java method replace the caller’s object reference?
Java passes all arguments by value. For object arguments, the copied value is a reference, so a method can mutate the referenced object but cannot rebind the caller's variable.
Basic · Collections
Why must equal HashMap keys have the same hash code?
HashMap uses a hash to select candidate storage and equals to find an equivalent key. Equal objects must have equal hashes, although unequal objects may collide.
Intermediate · Internals
What really happens when HashMap collisions exceed the tree threshold?
Java 8+ HashMap may treeify a heavily collided bucket, but the minimum table-capacity condition matters: at small capacities it resizes instead of immediately using a tree.
Advanced · Concurrency
Why is volatile count++ still a race?
volatile provides visibility and ordering guarantees for reads and writes, but count++ is a read-modify-write sequence. Two threads can read the same value and each publish the same increment.
Expert · Production debugging
How would you investigate rising JVM latency and old-generation usage?
Correlate p95/p99 latency with GC pauses, allocation rates and heap occupancy after full collections. High allocation pressure and retained objects are different problems.
Architect / Specialist · Architecture
Why don’t virtual threads remove the need for backpressure?
Virtual threads reduce the cost of blocking-thread concurrency, but they do not increase database connection capacity, CPU throughput or external-service rate limits.
Module — Coding Interview Problems & Solutions (Hands-on)
6 questions · 0 completed · 0%
Module — Coding Interview Problems & Solutions (Hands-on)
6 questions · 0 completed · 0%
Beginner · Strings
Reverse Unicode code points in Java
Return a new string with Unicode code points reversed, without splitting surrogate pairs.
Basic · Hashing
Find the first unique Unicode code point
Return the numeric code point of the first non-repeated code point, or -1 if absent.
Intermediate · Prefix sum
Count contiguous subarrays summing to K
Return the number of nonempty contiguous subarrays whose sum equals K.
Advanced · Streams
Compute department averages with collectors
Return average integer salary per department without mutating the input list.
Expert · Concurrency
Implement thread-safe lazy initialization with the holder idiom
Return the same lazily initialized Registry instance to every ordinary caller in one class-loader domain.
Architect / Specialist · Production concurrency
Build a bounded producer-consumer channel with explicit completion
Transfer positive integers through a capacity-two queue, sum them in a consumer and terminate with an explicit reserved sentinel.
A–Z index
- Abstract Classes & Interfaces
- Arrays & Strings
- Build a bounded producer-consumer channel with explicit completion
- Can a Java method replace the caller’s object reference?
- Classes, Objects & Constructors
- Collections Framework
- Compute department averages with collectors
- Control Flow & Loops
- Count contiguous subarrays summing to K
- Design Patterns & SOLID
- Exception Handling
- Executors, CompletableFuture & Virtual Threads
- Find the first unique Unicode code point
- Functions Reference: Collections & Stream API
- Functions Reference: Core Utilities, Strings & Math
- Generics
- How would you investigate rising JVM latency and old-generation usage?
- Implement thread-safe lazy initialization with the holder idiom
- Java, JDK, JRE & JVM
- JVM Memory & Garbage Collection
- Lambdas & Stream API
- Methods & Recursion
- Multithreading Basics
- OOP: Encapsulation, Inheritance, Polymorphism
- Reverse Unicode code points in Java
- Variables, Data Types & Operators
- What really happens when HashMap collisions exceed the tree threshold?
- Why don’t virtual threads remove the need for backpressure?
- Why is volatile count++ still a race?
- Why must equal HashMap keys have the same hash code?
Can't find a Java topic you need for exams or placements? Request it and we'll add it.