โ† All topics

โ˜• Interview Prep

Java

equals and hashCode, collections internals, strings, exceptions, generics, streams, concurrency, the JVM and modern Java: what Java and Spring teams test.

๐Ÿ“˜ Learn it from scratch

Visual, hands-on lessons for every pattern in this topic. Do the lesson, then come back and the questions click.

100 questions, most asked first

Ranked by how often each question comes up in real interviews. #1 is the most common.

#1The equals() and hashCode() contractCore Java & OOPMediumFree#2How does HashMap work internally?CollectionsMediumFree#7Checked vs unchecked exceptionsExceptionsMediumFree#9Stack vs heap, and how garbage collection worksJVM & memoryMediumFreeUnlock 51 more Java questions ยท all 1,200 questions for $39/year (about 11ยข a day)See full access#14HashMap vs Hashtable vs ConcurrentHashMapConcurrencyMedium๐Ÿ”’#16Threads, Runnable and ExecutorServiceConcurrencyMedium๐Ÿ”’#17Java Streams: map, filter, reduce, collectStreams & lambdasMedium๐Ÿ”’#18Lambdas and functional interfacesStreams & lambdasMedium๐Ÿ”’#19Using Optional correctlyStreams & lambdasMedium๐Ÿ”’#20How to write an immutable classCore Java & OOPMedium๐Ÿ”’#22Generics and type erasureGenericsMedium๐Ÿ”’#25ConcurrentModificationException and fail-fast iteratorsCollectionsMedium๐Ÿ”’#28CompletableFuture and async compositionConcurrencyMedium๐Ÿ”’#30Writing a thread-safe singletonCore Java & OOPMedium๐Ÿ”’#31Autoboxing and the Integer cacheCore Java & OOPMedium๐Ÿ”’#33Memory leaks in a garbage-collected languageJVM & memoryMedium๐Ÿ”’#35AtomicInteger and compare-and-swapConcurrencyMedium๐Ÿ”’#38Default methods and the diamond problemCore Java & OOPMedium๐Ÿ”’#39Switch expressions and pattern matchingModern JavaMedium๐Ÿ”’#40Sealed classes and interfacesModern JavaMedium๐Ÿ”’#42Static nested, inner, local and anonymous classesCore Java & OOPMedium๐Ÿ”’#43Exception handling best practicesExceptionsMedium๐Ÿ”’#44PriorityQueue and heapsCollectionsMedium๐Ÿ”’#45Arrays.asList vs List.of vs unmodifiable listsCollectionsMedium๐Ÿ”’#46Virtual threads (Java 21)ConcurrencyMedium๐Ÿ”’#47ThreadLocal and its pitfallsConcurrencyMedium๐Ÿ”’#49Bytecode, the interpreter and the JITJVM & memoryMedium๐Ÿ”’#50groupingBy, flatMap and other collectorsStreams & lambdasMedium๐Ÿ”’#52Serialization and the transient keywordCore Java & OOPMedium๐Ÿ”’#53Reflection and annotationsCore Java & OOPMedium๐Ÿ”’#55Shallow vs deep copy, and clone()Core Java & OOPMedium๐Ÿ”’#57Intermediate vs terminal operations (streams are lazy)Streams & lambdasMedium๐Ÿ”’#58ReentrantLock and ReadWriteLock vs synchronizedConcurrencyMedium๐Ÿ”’#59CountDownLatch, CyclicBarrier and SemaphoreConcurrencyMedium๐Ÿ”’#60Unit testing with JUnit 5 and MockitoTestingMedium๐Ÿ”’#65What changed from Java 8 to Java 21?Modern JavaMedium๐Ÿ”’#66Making your own class work in a for-each loopCollectionsMedium๐Ÿ”’#68OutOfMemoryError vs StackOverflowErrorJVM & memoryMedium๐Ÿ”’#69Dependency injection and inversion of controlSpring & ecosystemMedium๐Ÿ”’#71How does Spring Boot auto-configuration work?Spring & ecosystemMedium๐Ÿ”’#72Spring bean scopes and lifecycleSpring & ecosystemMedium๐Ÿ”’#75Lazy vs eager loading and LazyInitializationExceptionSpring & ecosystemMedium๐Ÿ”’#76Building a clean REST endpoint in SpringSpring & ecosystemMedium๐Ÿ”’#78Mutable objects as HashMap keysCollectionsMedium๐Ÿ”’#79SOLID principles in JavaCore Java & OOPMedium๐Ÿ”’#82Sizing and shutting down thread poolsConcurrencyMedium๐Ÿ”’#83Check-then-act races and atomic map operationsConcurrencyMedium๐Ÿ”’#85Initialization order of static and instance membersCore Java & OOPMedium๐Ÿ”’#86Checked exceptions inside lambdas and streamsStreams & lambdasMedium๐Ÿ”’#88How does Java sort, and is it stable?CollectionsMedium๐Ÿ”’#90Stopping a thread and handling InterruptedExceptionConcurrencyMedium๐Ÿ”’#91Running the JVM in containersJVM & memoryMedium๐Ÿ”’#93The Java Platform Module SystemModern JavaMedium๐Ÿ”’#95Integration tests with Spring and TestcontainersTestingMedium๐Ÿ”’#96Testing code that depends on timeTestingMedium๐Ÿ”’