← 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#3String immutability, the string pool, and == vs equalsCore Java & OOPEasyFree#4Abstract class vs interfaceCore Java & OOPEasyFree#5ArrayList vs LinkedListCollectionsEasyFree#6final vs finally vs finalizeCore Java & OOPEasyFree#7Checked vs unchecked exceptionsExceptionsMediumFree#8JDK vs JRE vs JVMJVM & memoryEasyFree#9Stack vs heap, and how garbage collection worksJVM & memoryMediumFree#10Overloading vs overridingCore Java & OOPEasyFreeUnlock 90 more Java questions Β· all 1,200 questions for $39/year (about 11Β’ a day)See full access#11String vs StringBuilder vs StringBufferCore Java & OOPEasyπŸ”’#12What does static mean?Core Java & OOPEasyπŸ”’#13Comparable vs ComparatorCollectionsEasyπŸ”’#14HashMap vs Hashtable vs ConcurrentHashMapConcurrencyMediumπŸ”’#15synchronized vs volatileConcurrencyHardπŸ”’#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πŸ”’#21Is Java pass-by-value or pass-by-reference?Core Java & OOPEasyπŸ”’#22Generics and type erasureGenericsMediumπŸ”’#23try-with-resources and AutoCloseableExceptionsEasyπŸ”’#24HashSet vs LinkedHashSet vs TreeSetCollectionsEasyπŸ”’#25ConcurrentModificationException and fail-fast iteratorsCollectionsMediumπŸ”’#26public, protected, package-private and privateCore Java & OOPEasyπŸ”’#27What is a deadlock, and how do you prevent it?ConcurrencyHardπŸ”’#28CompletableFuture and async compositionConcurrencyMediumπŸ”’#29What are records, and when should you use them?Modern JavaEasyπŸ”’#30Writing a thread-safe singletonCore Java & OOPMediumπŸ”’#31Autoboxing and the Integer cacheCore Java & OOPMediumπŸ”’#32HashMap vs LinkedHashMap vs TreeMapCollectionsEasyπŸ”’#33Memory leaks in a garbage-collected languageJVM & memoryMediumπŸ”’#34How class loading worksJVM & memoryHardπŸ”’#35AtomicInteger and compare-and-swapConcurrencyMediumπŸ”’#36Thread lifecycle and statesConcurrencyEasyπŸ”’#37wait/notify and the producer-consumer problemConcurrencyHardπŸ”’#38Default methods and the diamond problemCore Java & OOPMediumπŸ”’#39Switch expressions and pattern matchingModern JavaMediumπŸ”’#40Sealed classes and interfacesModern JavaMediumπŸ”’#41Polymorphism and dynamic dispatchCore Java & OOPEasyπŸ”’#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πŸ”’#48Choosing a garbage collectorJVM & memoryHardπŸ”’#49Bytecode, the interpreter and the JITJVM & memoryMediumπŸ”’#50groupingBy, flatMap and other collectorsStreams & lambdasMediumπŸ”’#51Wildcards, bounded types and PECSGenericsHardπŸ”’#52Serialization and the transient keywordCore Java & OOPMediumπŸ”’#53Reflection and annotationsCore Java & OOPMediumπŸ”’#54Enums are full classesCore Java & OOPEasyπŸ”’#55Shallow vs deep copy, and clone()Core Java & OOPMediumπŸ”’#56When are parallel streams a good idea?Streams & lambdasHardπŸ”’#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πŸ”’#61The Java Memory Model and happens-beforeConcurrencyHardπŸ”’#62Integer overflow and numeric typesCore Java & OOPEasyπŸ”’#63Why not use double for money?Core Java & OOPEasyπŸ”’#64Local variable type inference with varModern JavaEasyπŸ”’#65What changed from Java 8 to Java 21?Modern JavaMediumπŸ”’#66Making your own class work in a for-each loopCollectionsMediumπŸ”’#67Strong, soft, weak and phantom referencesJVM & memoryHardπŸ”’#68OutOfMemoryError vs StackOverflowErrorJVM & memoryMediumπŸ”’#69Dependency injection and inversion of controlSpring & ecosystemMediumπŸ”’#70The Builder patternCore Java & OOPEasyπŸ”’#71How does Spring Boot auto-configuration work?Spring & ecosystemMediumπŸ”’#72Spring bean scopes and lifecycleSpring & ecosystemMediumπŸ”’#73@Transactional and its pitfallsSpring & ecosystemHardπŸ”’#74The N+1 query problem in JPA / HibernateSpring & ecosystemHardπŸ”’#75Lazy vs eager loading and LazyInitializationExceptionSpring & ecosystemMediumπŸ”’#76Building a clean REST endpoint in SpringSpring & ecosystemMediumπŸ”’#77Maven vs Gradle and dependency managementSpring & ecosystemEasyπŸ”’#78Mutable objects as HashMap keysCollectionsMediumπŸ”’#79SOLID principles in JavaCore Java & OOPMediumπŸ”’#80Configuration and profiles in Spring BootSpring & ecosystemEasyπŸ”’#81The Fork/Join framework and work stealingConcurrencyHardπŸ”’#82Sizing and shutting down thread poolsConcurrencyMediumπŸ”’#83Check-then-act races and atomic map operationsConcurrencyMediumπŸ”’#84String.split surprisesCore Java & OOPEasyπŸ”’#85Initialization order of static and instance membersCore Java & OOPMediumπŸ”’#86Checked exceptions inside lambdas and streamsStreams & lambdasMediumπŸ”’#87Method referencesStreams & lambdasEasyπŸ”’#88How does Java sort, and is it stable?CollectionsMediumπŸ”’#89Why use ArrayDeque instead of Stack?CollectionsEasyπŸ”’#90Stopping a thread and handling InterruptedExceptionConcurrencyMediumπŸ”’#91Running the JVM in containersJVM & memoryMediumπŸ”’#92Diagnosing high CPU or a hung Java serviceJVM & memoryHardπŸ”’#93The Java Platform Module SystemModern JavaMediumπŸ”’#94equals() with inheritance (getClass vs instanceof)Core Java & OOPHardπŸ”’#95Integration tests with Spring and TestcontainersTestingMediumπŸ”’#96Testing code that depends on timeTestingMediumπŸ”’#97Logging well in Java servicesSpring & ecosystemEasyπŸ”’#98Handling null and NullPointerExceptionCore Java & OOPEasyπŸ”’#99EnumMap and EnumSetCollectionsEasyπŸ”’#100Why naive Java benchmarks lie (JMH)JVM & memoryHardπŸ”’