Java Interview Prep
From equals() to the JVM, with real code
The Java fundamentals interviewers test: object-oriented design, collections, streams, exceptions, concurrency, the JVM, I/O and classic design patterns.
- Topics
- 39
- Questions
- 3928
- Flashcards
- 3505
What you'll cover
Open a topic to preview its key ideas, the Learn step of the Sharp method.
Object-oriented programming
492 Q · 490 cardsClasses, interfaces, equals/hashCode, immutability.
492 questions with answers →Test this topic →Key ideas
==compares references for objects;equals()compares logical equality.- Override
equalsandhashCodetogether: equal objects must have equal hash codes. - Interfaces can have
defaultandstaticmethods (Java 8+) but no instance state. Abstract classes can hold state and constructors. Stringis immutable; compile-time constant strings are interned.
Collections
158 Q · 155 cardsList, Set, Map implementations and their trade-offs.
158 questions with answers →Test this topic →Key ideas
ArrayList: O(1) random access, amortized O(1) append.LinkedList: O(n) indexed access.HashMap: O(1) average get/put; one null key allowed.TreeMap: sorted, O(log n).List.remove(int)removes by index;remove(Object)removes by value. Watch out withList<Integer>.Comparabledefines natural order;Comparatordefines alternative orders.
Streams & functional
4 Q · 3 cardsLambdas, intermediate vs terminal operations, Optional.
4 questions with answers →Test this topic →Key ideas
- A stream pipeline is source → zero or more intermediate ops (lazy) → one terminal op (triggers execution).
- Pipelines process elements one at a time and short-circuit (
findFirst,anyMatch,limit). maptransforms 1→1;flatMaptransforms 1→many and flattens.Optional.orElse(x)always evaluatesx;orElseGet(supplier)only when empty.
Exceptions
160 Q · 158 cardsChecked vs unchecked, try-with-resources, finally.
160 questions with answers →Test this topic →Key ideas
- Checked exceptions (
IOException) must be caught or declared; unchecked (RuntimeExceptionand subclasses) needn't be. - try-with-resources closes resources automatically, in reverse order of declaration; exceptions from
close()are attached as *suppressed*. finallyruns on normal exit, return or exception, but not afterSystem.exit().
- Checked exceptions (
Concurrency basics
110 Q · 108 cardsThreads, synchronization, volatile, atomics, executors.
110 questions with answers →Test this topic →Key ideas
count++is read-modify-write and not atomic; unsynchronized threads lose updates.synchronizedgives mutual exclusion and visibility.volatilegives visibility and ordering, but not atomicity.- Prefer
java.util.concurrent:AtomicInteger,LongAdder,ConcurrentHashMap,ExecutorService. shutdown()stops accepting tasks and lets queued ones finish;shutdownNow()also interrupts running tasks.
JVM & runtime
4 Q · 3 cardsMemory areas, class loading, JIT, garbage collection.
4 questions with answers →Test this topic →Key ideas
- Objects live on the heap; each thread has a stack of frames holding locals and references.
- Class lifecycle: loading → linking (verify, prepare, resolve) → initialization (static initializers run once).
- Construction order: superclass first. Static blocks run at class initialization; instance initializers run before the constructor body.
- The JIT compiles hot bytecode to native code at runtime.
I/O
4 Q · 2 cardsStreams vs readers, buffering, NIO.2, serialization.
4 questions with answers →Test this topic →Key ideas
- Byte streams (
InputStream/OutputStream) vs character streams (Reader/Writer, which handle charsets). - Wrap with
BufferedReader/BufferedWriterto avoid one system call per character. - NIO.2:
PathandFiles(Files.readAllLines,Files.lines,Files.writeString). - Serialization needs
Serializable;transientandstaticfields aren't serialized. Never deserialize untrusted data.
- Byte streams (
Design patterns
98 Q · 96 cardsCreational, structural and behavioral patterns in Java.
98 questions with answers →Test this topic →Key ideas
- Creational: Factory Method, Builder, Singleton. Structural: Adapter, Decorator, Proxy. Behavioral: Strategy, Observer, Template Method.
- Java I/O is the textbook Decorator:
new BufferedInputStream(new FileInputStream(f)). - Strategy swaps an algorithm behind an interface; with lambdas it's often a functional interface.
- Singletons need care with threads and serialization. An
enumsingleton handles both.
API Evolution
27 Q · 27 cardsMigration Strategy, Modern Date and Time
27 questions with answers →Test this topic →Authentication
81 Q · 81 cardsJSON Web Tokens (JWT), JWT Signatures, Plaintext Passwords, Salting and BCrypt
81 questions with answers →Test this topic →Build Tools
48 Q · 48 cardsBuild Lifecycle, Continuous Integration, Dependency Management
48 questions with answers →Test this topic →Career Growth
20 Q · 20 cardsThe STAR Framework, Transitioning to Senior
20 questions with answers →Test this topic →Core Java
473 Q · 472 cardsBigDecimal and Money, Code Reading and Debugging, Code Reading and Refactoring to Objects, Code Reading and State Safety, Code Reading with Collections, Code Reading with Exceptions
473 questions with answers →Test this topic →Dependency Injection
26 Q · 25 cardsConstructor vs Field Injection
26 questions with answers →Test this topic →Distributed Resilience
67 Q · 67 cardsCircuit Breakers, Distributed Tracing, Eventual Consistency (Sagas), Exponential Backoff Retries, Message Brokers (Kafka)
67 questions with answers →Test this topic →Engineering Interviews
91 Q · 89 cardsCode Review (Spotting Bugs), JVM Trivia, Live Coding Strategy, The STAR Framework
91 questions with answers →Test this topic →HTTP JSON APIs
27 Q · 27 cardsAPI Versioning, Jackson ObjectMapper, JSON Serialization
27 questions with answers →Test this topic →Java Annotations
73 Q · 73 cardsAnnotation Processors, Custom Annotations, Retention Policies
73 questions with answers →Test this topic →Java Interview Questions
400 Q · 0 cardsCollections • ArrayDeque as a Queue, Collections • ArrayDeque as a Stack, Collections • ArrayList vs LinkedList, Collections • Comparable vs Comparator, Collections • HashMap Internals, Collections • HashSet Membership and Deduplication
400 questions with answers →Test this topic →Java Threading
62 Q · 62 cardsAtomic Variables, ExecutorService, Race Conditions, Synchronized and Locks, The Volatile Keyword, Virtual Threads
62 questions with answers →Test this topic →Language Upgrades
67 Q · 67 cardsMigration Strategy, Pattern Matching, Sealed Classes
67 questions with answers →Test this topic →Memory Management
27 Q · 27 cardsMetaspace, OutOfMemoryErrors, Stack vs Heap
27 questions with answers →Test this topic →Microservice Architecture
99 Q · 99 cardsBounded Contexts, Database per Service, Docker Containerization, Eventual Consistency (Sagas), Kubernetes Orchestration, Message Brokers (Kafka)
99 questions with answers →Test this topic →Modern Java
185 Q · 185 cardsCleaner Domain Modeling, Enums, Java Records, Modern Java Design Choices, Records, Static Factory Methods
185 questions with answers →Test this topic →Networking
127 Q · 127 cardsAsynchronous HTTP, HttpClient Basics, Jackson ObjectMapper, JSON Serialization, Socket Programming, Timeouts and Retries
127 questions with answers →Test this topic →OWASP Vulnerabilities
64 Q · 64 cardsCross-Site Request Forgery (CSRF), Cross-Site Scripting (XSS), SQL Injection
64 questions with answers →Test this topic →Performance Tuning
67 Q · 67 cardsGarbage Collection Basics, OutOfMemoryErrors, Stop-The-World Pauses, Thread Dumps
67 questions with answers →Test this topic →Project Reactor
62 Q · 61 cardsFunctional Pipelines (flatMap), Project Reactor: Flux, Project Reactor: Mono
62 questions with answers →Test this topic →Project Structure
38 Q · 38 cardsContinuous Integration, Java Modules (JPMS)
38 questions with answers →Test this topic →Reactive Streams
120 Q · 120 cardsBackpressure Strategies, Blocking the Event Loop, Functional Pipelines (flatMap), Non-Blocking I/O (Event Loops), Publisher and Subscriber, Thread-Per-Request Bottleneck
120 questions with answers →Test this topic →Reflection API
77 Q · 77 cardsBreaking Encapsulation, Dynamic Class Loading, Method.invoke, MethodHandles
77 questions with answers →Test this topic →Software Architecture
60 Q · 60 cardsBuilder Pattern, Observer Pattern, Pattern Abuse
60 questions with answers →Test this topic →Spring Core
144 Q · 142 cardsApplication Properties, Bean Scope, Controllers, Services, Repositories, DTOs and Entities, Inversion of Control (IoC), Persistence and Validation
144 questions with answers →Test this topic →Spring Security
23 Q · 23 cardsSpring Security Filter Chain
23 questions with answers →Test this topic →SQL for Java Devs
172 Q · 171 cardsBatching, Indexes, JDBC, JOINs, PreparedStatements, Repository Pattern
172 questions with answers →Test this topic →System Design
39 Q · 39 cardsDefending Tradeoffs, Drawing the Blueprint
39 questions with answers →Test this topic →Testing
80 Q · 80 cardsController Testing, Integration Testing, Mocking with Mockito, Unit Testing with JUnit
80 questions with answers →Test this topic →
Question formats
Practice the formats you'll actually see. Code examples included.
- Multiple choice · 3906
- Fill in the blank · 3
- Select all that apply · 4
- What does this code output? · 6
- Drop-down cloze · 1
- Ordering · 2
- Matrix / grid · 2
- Interview answer · 3
- Highlight text · 1
Start Java Interview Prep
Create a free account to save progress, track weak topics and keep your streak.