← 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

Ordered so the most useful questions for learning each pattern come first.

#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πŸ”’