Interview Prep

Java

250 questions across 33 categories

Interview Me →

50 of 50 questions

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