Interview Prep
Java
250 questions across 33 categories
50 of 50 questions
| # | Category | Question | Answer | ★ |
|---|---|---|---|---|
| 1 | JVM Internals | Explain the Java class loading process and the bootstrap/extension/application delegation model. | Click row to expand | |
| 2 | JVM Internals | What is the difference between JVM stack memory and heap memory? What is stored in each? | Click row to expand | |
| 3 | JVM Internals | Compare G1GC, ZGC, and Shenandoah. When would you choose each? | Click row to expand | |
| 4 | JVM Internals | What is JIT compilation? Explain the C1 vs C2 compiler tiers and when each kicks in. | Click row to expand | |
| 5 | JVM Internals | What are virtual threads (Project Loom, Java 21)? How do they differ from platform threads? | Click row to expand | |
| 6 | JVM Internals | Explain Java's escape analysis optimization and how it enables stack allocation and lock elision. | Click row to expand | |
| 7 | JVM Internals | What is Metaspace? How does it differ from PermGen, and what can cause a Metaspace OOM? | Click row to expand | |
| 8 | JVM Internals | What is the Java Memory Model (JMM)? Explain happens-before and why it matters for concurrent code. | Click row to expand | |
| 9 | Concurrency | What is the difference between synchronized and ReentrantLock? When should you prefer one over the other? | Click row to expand | |
| 10 | Concurrency | Explain the volatile keyword. What guarantees does it provide, and what does it NOT guarantee? | Click row to expand | |
| 11 | Concurrency | What is a thread pool? Compare FixedThreadPool, CachedThreadPool, and ForkJoinPool. | Click row to expand | |
| 12 | Concurrency | How does CompletableFuture work? Explain the difference between thenApply, thenCompose, and thenCombine. | Click row to expand | |
| 13 | Concurrency | What is ThreadLocal? What are its common use cases and pitfalls, especially in thread pools? | Click row to expand | |
| 14 | Concurrency | Explain ConcurrentHashMap internals. How does it achieve thread safety without locking the entire map? | Click row to expand | |
| 15 | Concurrency | What is a deadlock? How do you detect and prevent it? What is livelock and starvation? | Click row to expand | |
| 16 | Concurrency | What are the Atomic classes (AtomicInteger, AtomicReference, etc.)? How do they work internally? | Click row to expand | |
| 17 | Memory Management | How do you diagnose and fix a memory leak in a Java application? | Click row to expand | |
| 18 | Memory Management | Explain the difference between WeakReference, SoftReference, and PhantomReference. | Click row to expand | |
| 19 | Memory Management | What is String interning and the String pool? What are the performance implications? | Click row to expand | |
| 20 | Collections & Generics | Explain type erasure in Java generics. What are its limitations and how does it affect reflection? | Click row to expand | |
| 21 | Collections & Generics | What is the PECS principle (Producer Extends, Consumer Super)? Give a concrete example. | Click row to expand | |
| 22 | Collections & Generics | When would you use HashMap vs LinkedHashMap vs TreeMap vs EnumMap? What are the complexity differences? | Click row to expand | |
| 23 | Spring Framework | How does Spring's IoC container work? Explain BeanFactory vs ApplicationContext and bean lifecycle. | Click row to expand | |
| 24 | Spring Framework | What are the @Transactional pitfalls? Explain self-invocation, propagation, and isolation levels. | Click row to expand | |
| 25 | Spring Framework | How does Spring Boot autoconfiguration work? Explain @Conditional annotations and how to write a custom starter. | Click row to expand | |
| 26 | Spring Framework | What is Spring AOP? Explain join points, pointcuts, advice types, and JDK vs CGLIB proxies. | Click row to expand | |
| 27 | Design Patterns | Explain the difference between the Factory Method, Abstract Factory, and Builder patterns with Java examples. | Click row to expand | |
| 28 | Design Patterns | How do you implement a thread-safe Singleton in Java? What are the different approaches and tradeoffs? | Click row to expand | |
| 29 | Design Patterns | Explain the Strategy, Command, and Template Method patterns and when to use each. | Click row to expand | |
| 30 | Java 8+ Features | Explain Java Streams. What is the difference between intermediate and terminal operations? What are the pitfalls? | Click row to expand | |
| 31 | Java 8+ Features | What is Optional? How should it be used correctly, and what are the anti-patterns? | Click row to expand | |
| 32 | Java 8+ Features | Explain sealed classes and pattern matching for switch (Java 17-21). How do they enable algebraic data types? | Click row to expand | |
| 33 | Microservices & Architecture | Explain the Circuit Breaker pattern. How does Resilience4j implement it, and what are its states? | Click row to expand | |
| 34 | Microservices & Architecture | What is the Saga pattern? Compare choreography vs orchestration sagas for distributed transactions. | Click row to expand | |
| 35 | Microservices & Architecture | How does JPA handle the N+1 query problem? What are the solutions? | Click row to expand | |
| 36 | Microservices & Architecture | Explain event sourcing vs traditional CRUD. What are the tradeoffs and when is event sourcing appropriate? | Click row to expand | |
| 37 | Performance & Testing | How do you profile a Java application? What tools and JVM flags are useful for performance analysis? | Click row to expand | |
| 38 | Performance & Testing | What is reactive programming in Java? Compare Project Reactor (Flux/Mono) vs RxJava vs virtual threads for I/O-bound workloads. | Click row to expand | |
| 39 | Performance & Testing | What is the equals/hashCode contract in Java? What breaks when you violate it with collections? | Click row to expand | |
| 40 | Performance & Testing | How do you write effective unit tests for concurrent Java code? What are the pitfalls of testing multithreaded code? | Click row to expand | |
| 41 | Design Patterns | What are SOLID principles? Give a concrete Java violation and fix for each. | Click row to expand | |
| 42 | Java 8+ Features | Explain the Fork/Join framework and RecursiveTask. How does work stealing work? | Click row to expand | |
| 43 | Spring Framework | What is Spring Security's filter chain? Explain how authentication and authorization work. | Click row to expand | |
| 44 | Microservices & Architecture | What is CQRS? How does it combine with event sourcing, and what are the consistency tradeoffs? | Click row to expand | |
| 45 | Performance & Testing | What is database connection pooling? How do you tune HikariCP in a Spring Boot application? | Click row to expand | |
| 46 | Collections & Generics | Explain the internal structure of HashMap. What happens during a put() operation? What is the load factor? | Click row to expand | |
| 47 | Java 8+ Features | What are records in Java? How do they differ from Lombok @Data? When shouldn't you use records? | Click row to expand | |
| 48 | Concurrency | What is the producer-consumer pattern? Compare BlockingQueue implementations for this use case. | Click row to expand | |
| 49 | Design Patterns | Explain the Decorator pattern vs Inheritance. How is it used in Java I/O streams? | Click row to expand | |
| 50 | Microservices & Architecture | What is service mesh? How does it differ from API Gateway, and when would you use Istio or Linkerd? | Click row to expand |