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