500+ Java Interview Questions & Answers
Comprehensive preparation guide covering 20 key backend domains with structured explanations for Junior, Middle, and Senior engineers.
Explore 20 Topic Clusters
Choose a domain to start reviewing structured answers with under-the-hood breakdowns and interview cheat sheets.
1. Databases SQL PostgreSQL
Indexes, B-Trees, MVCC, VACUUM, JOINs, window functions, and query optimization.
2. Design Patterns
GoF patterns in Java: Singleton, Factory, Strategy, Observer, Decorator, and Proxies.
3. Memory & Garbage Collection
JVM Heap, Stack, Metaspace, G1, ZGC, memory leaks, OutOfMemoryError, and profiling.
4. Collections Framework
ArrayList, LinkedList, TreeSet, ConcurrentHashMap, fail-fast vs fail-safe iterators.
5. Spring & Spring Boot
IoC, DI, Bean Lifecycle, BeanPostProcessor, auto-configuration, actuators, and proxies.
6. REST & HTTP
HTTP methods, idempotency, status codes, REST maturity model, and API design principles.
7. Exceptions Handling
Checked vs Unchecked, try-with-resources, AutoCloseable, suppressed exceptions, best practices.
8. Stream API
Intermediate & terminal operations, collectors, parallel streams, reduce, Spliterator.
9. Multithreading & Concurrency
JMM, synchronized, volatile, CAS, Atomic classes, ThreadPools, Virtual Threads, and Deadlocks.
10. HashMap, equals & hashCode
Internal bucket hashing, treeification (Red-Black trees), collision handling, and contracts.
11. Transactions
ACID properties, isolation levels, propagation types in Spring `@Transactional`, and 2PC.
12. String Internals
String Constant Pool, Compact Strings, StringBuilder vs StringBuffer, immutability benefits.
13. Immutability
Defensive copying, unmodifiable wrappers, Java Records, thread safety through immutability.
14. Docker & Kubernetes
Containerization, multi-stage builds, Pods, Services, Deployments, ConfigMaps, and Probes.
15. Apache Kafka
Topics, partitions, consumer groups, delivery semantics, offsets, idempotence, and rebalances.
16. Hibernate & JPA
Entity lifecycle, N+1 query problem, fetch strategies, L1/L2 caches, and optimistic locking.
17. Microservices Architecture
Service Discovery, API Gateway, Circuit Breaker, Saga Pattern, Distributed Tracing, CQRS.
18. OOP & SOLID Principles
Encapsulation, Polymorphism, Inheritance vs Composition, Single Responsibility, LSP, DIP.
19. CompletableFuture & Async
Asynchronous composition, exception handling, allOf / anyOf, thread pool management.
20. Records & Generics
Java Records, Type Erasure, Wildcards `? extends / super`, PECS rule, Bridge methods.