Study Guide
Master Java for Product Company Interviews
A structured, topic-by-topic deep-dive covering Core Java through System Design. Built for engineers with 4+ years of experience preparing for Amazon, Google, Microsoft, Uber, Flipkart, and other top product companies.
Core Java Deep Dive
Language Fundamentals
- Primitives vs Objects — memory layout, when auto-boxing happens
- Pass-by-value vs Pass-by-reference (Java is always pass-by-value)
- String internals — String Pool, immutability, why String is final
- StringBuilder vs StringBuffer vs String — performance & thread-safety
- equals() and hashCode() contract — breaking it causes bugs in HashMap/HashSet
- Immutability — designing truly immutable classes (defensive copies)
- final, static, transient, volatile — exact semantics
- Autoboxing / Unboxing pitfalls (Integer caching -128 to 127)
- Wrapper classes deep dive
- Varargs — how they work under the hood
- Enums — constructors, methods, EnumSet, EnumMap
- Nested classes — static nested, inner, local, anonymous
- instanceof, pattern matching for instanceof (Java 16+)
- Object class methods — toString, equals, hashCode, clone, getClass, wait/notify
- clone() deep dive — shallow vs deep, Cloneable marker interface problems
- Serialization — Serializable, Externalizable, serialVersionUID, pitfalls
- Reflection API — Class, Method, Field, Constructor, performance cost
- Annotations — retention policies, meta-annotations, custom annotations
- Modules (JPMS) — module-info.java, requires, exports, opens
- Type casting — widening vs narrowing, ClassCastException
- Static and instance initializer blocks — execution order
I/O & NIO
- java.io streams — InputStream, OutputStream, Reader, Writer hierarchy
- Buffered streams, try-with-resources
- NIO — Channels, Buffers, Selectors
- NIO.2 (java.nio.file) — Path, Files, WatchService
- Asynchronous I/O (AsynchronousFileChannel)
OOP Deep Dive & SOLID
Four Pillars + Advanced OOP
- Encapsulation — when to break it (and why sometimes you should)
- Inheritance vs Composition — composition over inheritance principle
- Polymorphism — compile-time vs runtime, method overloading vs overriding
- Abstraction — abstract classes vs interfaces (Java 8+ default methods)
- Static vs Dynamic binding
- Method hiding vs overriding
- Covariant return types
- Diamond problem and how Java solves it
SOLID Principles
- Single Responsibility Principle (SRP)
- Open/Closed Principle (OCP)
- Liskov Substitution Principle (LSP) — classic violations
- Interface Segregation Principle (ISP)
- Dependency Inversion Principle (DIP)
- Cohesion & Coupling — spotting them in code reviews
- DRY, KISS, YAGNI — when breaking them is justified
Collections Framework Internals
List, Set, Queue, Deque
- ArrayList internals — capacity, growth factor (1.5x), fail-fast
- LinkedList — doubly linked, when it beats ArrayList
- CopyOnWriteArrayList — use cases & cost
- HashSet, LinkedHashSet, TreeSet — ordering guarantees
- EnumSet — bit vector implementation
- PriorityQueue — binary heap internals
- ArrayDeque vs LinkedList as Queue/Stack
- BlockingQueue implementations — ArrayBlockingQueue, LinkedBlockingQueue, PriorityBlockingQueue, DelayQueue, SynchronousQueue
- Immutable collections — List.of(), Map.of(), Set.of() (Java 9+)
Map Family (Most Asked)
- HashMap internals — hash function, buckets, load factor (0.75), resize, treeification (Java 8+)
- HashMap collision handling — linked list → red-black tree
- LinkedHashMap — access-order vs insertion-order (LRU cache)
- TreeMap — red-black tree, NavigableMap
- WeakHashMap, IdentityHashMap, EnumMap
- ConcurrentHashMap — segment locking (pre-Java 8) vs CAS + synchronized (Java 8+)
- Hashtable vs ConcurrentHashMap vs Collections.synchronizedMap
- Fail-fast vs Fail-safe iterators
Utilities & Best Practices
- Collections utility class — sort, binarySearch, unmodifiable*, synchronized*
- Arrays utility class
- Choosing the right collection — decision matrix
- Concurrent collections overview — ConcurrentSkipListMap, ConcurrentLinkedQueue, etc.
- NavigableSet, NavigableMap interfaces
Generics & Type System
Deep Generics
- Type erasure — what happens at runtime
- Bounded type parameters — extends, super
- Wildcards — ? extends T (producer), ? super T (consumer) — PECS principle
- Generic methods, constructors
- Type inference & diamond operator
- Bridge methods generated by compiler
- Restrictions — no primitives, no instanceof with parameterized types, no arrays of generics
- Recursive type bounds (e.g. Comparable<T extends Comparable<T>>)
Exception Handling & Best Practices
Exception Hierarchy & Patterns
- Checked vs Unchecked exceptions — when to use which
- Exception hierarchy — Throwable, Error, Exception, RuntimeException
- try-with-resources (AutoCloseable)
- Multi-catch, rethrowing with precise types
- Custom exceptions — when and how
- Exception wrapping / translation pattern
- Suppressed exceptions
- Best practices — never catch Throwable, don't swallow, don't use exceptions for control flow
- StackTraceElement & performance cost of exceptions
Modern Java (8 → 25)
Java 8 Foundations
- Lambda expressions — effectively final, method references
- Functional interfaces — Predicate, Function, Consumer, Supplier, BiFunction, UnaryOperator
- Stream API — intermediate vs terminal, lazy evaluation, short-circuiting
- Collectors — groupingBy, partitioningBy, toMap, collectingAndThen
- Optional — correct usage, orElse vs orElseGet, flatMap, avoid get()
- Default & static methods in interfaces
- New Date/Time API — LocalDate, LocalDateTime, ZonedDateTime, Instant, Duration, Period, DateTimeFormatter
- CompletableFuture basics
Java 9 – 17 (LTS Focus)
- Modules (JPMS)
- Private methods in interfaces (Java 9)
- var (local variable type inference) — Java 10
- HTTP Client (java.net.http) — Java 11
- Switch expressions & yield (Java 14)
- Text blocks (Java 15)
- Records — canonical constructor, compact constructor, limitations
- Sealed classes & interfaces (Java 17)
- Pattern matching for switch (preview → final)
- Helpful NullPointerExceptions
Java 21 – 25 (Latest LTS & Beyond)
- Virtual Threads (final in 21)
- Pattern Matching for switch (final)
- Record Patterns
- Sequenced Collections (Java 21)
- String Templates (preview)
- Unnamed patterns & variables (_)
- Structured Concurrency (preview → evolving)
- Scoped Values (replacement for ThreadLocal in virtual threads)
- Foreign Function & Memory API (Project Panama)
- Stream gatherers (Java 22+)
- Collectors.teeing (Java 12+)
Functional Programming Patterns
- Function composition — andThen, compose chains
- Currying & partial application in Java
- Monadic patterns — Optional as monad, flatMap chaining
- Immutable data pipelines with Streams
- Higher-order functions and strategy via lambdas
- Pure functions, side-effect management
Multithreading & Concurrency
Basics & Thread Lifecycle
- Process vs Thread
- Thread lifecycle states
- Runnable vs Callable vs Thread
- synchronized — method vs block, intrinsic locks, reentrancy
- wait(), notify(), notifyAll() — producer-consumer classic
- Thread interruption — interrupt(), interrupted(), isInterrupted()
- Daemon threads vs user threads
- Thread.sleep() vs Object.wait() differences
Java Memory Model & Visibility
- Java Memory Model (JMM) — happens-before relationship
- volatile — visibility + ordering, not atomicity
- Race conditions, data races
- Double-checked locking & volatile
- Happens-before rules (program order, monitor lock, volatile, thread start/join, etc.)
Locks & Synchronizers
- ReentrantLock — fair vs non-fair, tryLock, lockInterruptibly
- ReadWriteLock / StampedLock
- Condition objects
- CountDownLatch, CyclicBarrier, Phaser, Semaphore, Exchanger
- Atomic classes — AtomicInteger, AtomicReference, Atomic*FieldUpdater, LongAdder
- CAS (Compare-And-Swap) — ABA problem
- ThreadLocal — memory leaks with thread pools
Executor Framework & Advanced
- ExecutorService, ThreadPoolExecutor internals — corePoolSize, maxPoolSize, queue, rejection policies
- Thread pool sizing — CPU-bound vs I/O-bound heuristics
- ScheduledExecutorService
- Future, FutureTask, CompletableFuture deep dive (thenCompose, thenCombine, exceptionally, handle, whenComplete)
- ForkJoinPool — work-stealing algorithm, RecursiveTask/RecursiveAction
- Parallel Streams under the hood
- Deadlock, Livelock, Starvation — detection & prevention
- Common concurrency bugs & how to debug them
Virtual Threads & Project Loom
Virtual Threads (Java 21+)
- Platform threads vs Virtual threads
- How virtual threads work — carrier threads, mounting/unmounting
- Creating virtual threads — Thread.ofVirtual(), Executors.newVirtualThreadPerTaskExecutor()
- Pinning — synchronized blocks & native frames cause pinning
- -Djdk.tracePinnedThreads=full
- When virtual threads help (I/O bound) vs don't (CPU bound)
- ThreadLocal issues with millions of virtual threads → ScopedValue
- Spring Boot integration — spring.threads.virtual.enabled
Structured Concurrency
- StructuredTaskScope — ShutdownOnFailure, ShutdownOnSuccess
- fork → join → throwIfFailed lifecycle
- Why structured concurrency improves cancellation & observability
- ScopedValue as structured replacement for ThreadLocal
JVM Internals, GC & Performance
JVM Architecture
- Class Loader subsystem — Bootstrap, Extension/Platform, Application, custom loaders
- Class loading phases — Loading, Linking (verify, prepare, resolve), Initialization
- Runtime Data Areas — Method Area / Metaspace, Heap, Stack, PC Register, Native Method Stack
- Execution Engine — Interpreter, JIT Compiler (C1/C2), GC
- JIT compilation — tiered compilation, hot methods, deoptimization
- Native Method Interface (JNI) basics
Memory & Garbage Collection
- Heap structure — Young (Eden + Survivor), Old/Tenured, Metaspace
- Object allocation — TLAB, escape analysis, scalar replacement
- GC Algorithms — Serial, Parallel, CMS (deprecated), G1, ZGC, Shenandoah
- G1 GC internals — regions, remembered sets, concurrent marking
- ZGC / Shenandoah — low-latency, colored pointers / Brooks pointers
- GC tuning flags — -Xms, -Xmx, -XX:+UseG1GC, -XX:MaxGCPauseMillis, etc.
- OutOfMemoryError types — Heap, Metaspace, Stack, Direct buffer, GC overhead
- Memory leaks in Java — common causes (listeners, caches, ThreadLocal, classloaders)
- Soft, Weak, Phantom references
- Off-heap memory — DirectByteBuffer, memory-mapped files
- String deduplication in G1, Compact Strings (Java 9+)
Profiling & Diagnostics
- jvisualvm, jconsole, Java Flight Recorder (JFR), async-profiler
- jstack, jmap, jcmd, jstat
- Heap dumps analysis (Eclipse MAT, VisualVM)
- GraalVM — AOT, native images, startup & memory benefits
- AppCDS (Application Class Data Sharing) — faster startup
Design Patterns & Architecture
Creational
- Singleton — eager, lazy, double-checked, enum, Bill Pugh, thread-safety issues
- Factory Method & Abstract Factory
- Builder (and telescoping constructor problem)
- Prototype
- Object Pool
Structural
- Adapter, Bridge, Composite
- Decorator (heavily used in Java I/O & Spring)
- Facade, Flyweight, Proxy (static, dynamic, JDK vs CGLIB)
Behavioral
- Strategy, Observer, Command, Template Method
- Chain of Responsibility, State, Mediator, Memento, Visitor, Iterator
- Interpreter
Architecture Styles & Modern Patterns
- Layered, Hexagonal (Ports & Adapters), Clean Architecture
- Domain-Driven Design basics — Aggregates, Entities, Value Objects, Bounded Contexts, Ubiquitous Language
- CQRS & Event Sourcing
- Saga pattern (choreography vs orchestration)
- Outbox pattern, Inbox pattern
- Circuit Breaker, Bulkhead, Retry, Timeout, Fallback
Data Structures & Algorithms
Must-Know Structures & Algorithms
- Arrays & Strings — two pointers, sliding window, prefix sums
- Linked Lists — reverse, cycle detection, merge, LRU design
- Stacks & Queues — monotonic stack, next greater element
- Trees — Binary Tree, BST, Trie, Segment Tree, Fenwick (basics)
- Heaps / Priority Queues — top-K, median finding
- Graphs — BFS, DFS, Dijkstra, Topological sort, Union-Find
- Hashing — custom designs, collision strategies
- Sorting — merge, quick, counting, radix (when to use)
- Searching — binary search variants (lower/upper bound)
- Dynamic Programming — classic patterns (knapsack, LCS, LIS, grid paths)
- Recursion & Backtracking
- Greedy algorithms
- Bit manipulation
- Complexity analysis — time/space, amortized
System Design Friendly Data Structures
- Designing LRU / LFU Cache
- Designing Rate Limiter
- Designing Key-Value Store (simplified)
- Bloom Filters — probabilistic data structure, use cases
- Skip Lists — used in Redis sorted sets, ConcurrentSkipListMap
Spring Core & AOP
IoC & Dependency Injection
- Inversion of Control vs Dependency Injection
- BeanFactory vs ApplicationContext
- Bean lifecycle — Instantiation → Populate → Aware interfaces → BeanPostProcessor → @PostConstruct → Ready → @PreDestroy
- Bean scopes — singleton, prototype, request, session, application, websocket
- Constructor vs Setter vs Field injection — why constructor is preferred
- @Autowired, @Qualifier, @Primary, @Resource, @Inject
- Circular dependencies — how Spring handles (and when it fails)
- @Component, @Service, @Repository, @Controller stereotype annotations
- @Configuration, @Bean, @ComponentScan, @Import
- Conditional beans — @Conditional, @ConditionalOn*
- Environment, PropertySources, @Value, @ConfigurationProperties
- Profiles — @Profile, spring.profiles.active
- Spring Events — ApplicationEventPublisher, @EventListener, @Async events
AOP
- Aspect, Advice, Pointcut, Join Point, Weaving
- @Aspect, @Before, @After, @AfterReturning, @AfterThrowing, @Around
- Pointcut expressions — execution, within, args, @annotation, bean
- Proxy types — JDK dynamic proxy vs CGLIB
- Self-invocation problem (proxy bypass)
- Order of aspects (@Order)
Transactions
- @Transactional — propagation (REQUIRED, REQUIRES_NEW, NESTED, etc.)
- Isolation levels — READ_UNCOMMITTED → SERIALIZABLE
- Rollback rules — rollbackFor, noRollbackFor
- Proxy-based transaction management limitations
- Programmatic transactions (TransactionTemplate)
Spring Boot
Core Concepts
- Auto-configuration — how it works (spring.factories / AutoConfiguration.imports)
- @SpringBootApplication = @Configuration + @EnableAutoConfiguration + @ComponentScan
- Starters — spring-boot-starter-web, data-jpa, security, test, etc.
- application.properties / application.yml — hierarchical, profiles
- Externalized configuration — command line, env vars, config server
- @ConfigurationProperties — type-safe config, validation
- Embedded servers — Tomcat, Jetty, Undertow, Netty (WebFlux)
- Actuator — health, metrics, info, custom endpoints, security
- DevTools, LiveReload
- Logging configuration (Logback defaults, SLF4J)
- Fat JAR / executable JAR, layers
- Spring Boot 3.x changes — Jakarta EE, AOT, Native Image support
- Spring Boot Docker support — Buildpacks, layered JARs
- GraalVM native image with Spring Boot — configuration, limitations
Spring Data / JPA / Hibernate
JPA & Hibernate Internals
- Entity lifecycle — Transient, Managed, Detached, Removed
- @Entity, @Id, @GeneratedValue strategies
- Relationships — @OneToOne, @OneToMany, @ManyToOne, @ManyToMany + cascade & orphanRemoval
- FetchType.LAZY vs EAGER — N+1 problem & solutions (JOIN FETCH, EntityGraph, batch size)
- JPQL, Criteria API, Native queries
- First-level cache (Session/PersistenceContext) vs Second-level cache
- Dirty checking, Flush modes
- Optimistic locking (@Version) vs Pessimistic locking
- Inheritance strategies — SINGLE_TABLE, JOINED, TABLE_PER_CLASS
- @Embeddable, @Embedded, @ElementCollection
- Spring Data JPA — Repository interfaces, derived queries, @Query, Specifications, QueryDSL
- Pagination & Sorting
- Auditing — @CreatedDate, @LastModifiedDate, AuditorAware
- Transactions with JPA — Open Session in View anti-pattern
Other Spring Data Modules
- Spring Data Redis
- Spring Data MongoDB
- Spring Data JDBC (lighter alternative)
Spring Security & Application Security
Spring Security Core
- Authentication vs Authorization
- SecurityFilterChain (Spring Security 5.7+ / 6.x style)
- UserDetailsService, UserDetails, PasswordEncoder
- Form login, HTTP Basic, JWT-based authentication
- JWT — structure, signing (HS256/RS256), validation, refresh tokens
- OAuth2 / OpenID Connect — Authorization Code, Client Credentials, Resource Server
- Method security — @PreAuthorize, @PostAuthorize, @Secured, SpEL
- CSRF protection — when to disable (APIs), how tokens work
- CORS configuration
- Session management — concurrent sessions, fixation protection
- SecurityContext & SecurityContextHolder
- Custom filters, AuthenticationProvider, AuthenticationManager
Security Fundamentals (OWASP & Beyond)
- OWASP Top 10 — injection, broken auth, XSS, SSRF, security misconfiguration
- SQL injection prevention — parameterized queries, ORM protections
- XSS prevention — output encoding, Content Security Policy
- Encryption — symmetric (AES) vs asymmetric (RSA/ECDSA), at rest vs in transit
- Hashing — bcrypt, argon2, scrypt for passwords, SHA for integrity
- Secrets management — HashiCorp Vault, AWS Secrets Manager, environment variables
- API security — rate limiting, input validation, request signing
- Security headers — HSTS, X-Content-Type-Options, X-Frame-Options
Spring Web (MVC & WebFlux)
Spring MVC
- DispatcherServlet request lifecycle
- @Controller, @RestController, @RequestMapping hierarchy
- @RequestBody, @ResponseBody, HttpMessageConverters (Jackson)
- Validation — @Valid, @Validated, ConstraintViolation, custom validators
- Exception handling — @ControllerAdvice, @ExceptionHandler, ProblemDetail (RFC 7807)
- Interceptors vs Filters
- Content negotiation, versioning strategies
- File upload / download
- Async request handling (Callable, DeferredResult, WebAsyncTask)
Reactive (WebFlux)
- Reactive Streams — Publisher, Subscriber, Subscription, Processor
- Project Reactor — Mono, Flux, operators, backpressure
- WebFlux vs MVC — when to choose which
- Functional endpoints (RouterFunction) vs Annotated
- WebClient (reactive HTTP client)
- Error handling in reactive chains
API Design & Documentation
REST Best Practices
- Resource naming conventions — nouns not verbs, plural resources
- HTTP methods — GET, POST, PUT, PATCH, DELETE semantics
- Status codes — proper usage of 2xx, 3xx, 4xx, 5xx
- Richardson Maturity Model — levels 0 to 3
- HATEOAS — Hypermedia as the Engine of Application State
- API versioning strategies — URI path, header, query parameter
- Pagination patterns — offset, cursor-based, keyset
- Filtering, sorting, field selection (sparse fieldsets)
- Idempotency keys for safe retries
- Error response standards — RFC 7807 Problem Details
Documentation & Contracts
- OpenAPI 3.0 / Swagger — specification structure
- Springdoc OpenAPI — auto-generation, customization
- API-first vs Code-first design
- Backward compatibility & breaking change management
GraphQL & gRPC
GraphQL
- Schema definition — types, queries, mutations, subscriptions
- Spring for GraphQL — @SchemaMapping, @QueryMapping, @MutationMapping
- N+1 problem in GraphQL — DataLoader pattern, batch loading
- Pagination in GraphQL — Relay cursor connections
- Error handling and partial responses
- GraphQL vs REST — trade-offs, when to choose which
gRPC & Protocol Buffers
- Protocol Buffers — .proto files, message types, code generation
- gRPC service definition — unary, server streaming, client streaming, bidirectional
- gRPC vs REST — performance, type safety, streaming, browser support
- gRPC with Spring Boot — grpc-spring-boot-starter
- Error handling — Status codes, metadata, deadlines
- gRPC interceptors and middleware
Microservices & Spring Cloud
Architecture & Patterns
- Monolith vs Microservices — trade-offs
- Service Discovery — Eureka, Consul, Kubernetes DNS
- API Gateway — Spring Cloud Gateway, routing, filters, rate limiting
- Config management — Spring Cloud Config, Kubernetes ConfigMaps/Secrets
- Client-side load balancing — Spring Cloud LoadBalancer
- Circuit Breaker — Resilience4j (or older Hystrix)
- Distributed tracing — Sleuth → Micrometer Tracing + Zipkin/Jaeger
- Inter-service communication — RestTemplate → WebClient / OpenFeign
- Service mesh basics (Istio, Linkerd) — understanding the concept
- Saga, CQRS, Event-Driven microservices
- Distributed transactions challenges (2PC vs Saga)
- Idempotency, eventual consistency
Messaging (Kafka, RabbitMQ)
Apache Kafka
- Core concepts — Topics, Partitions, Offsets, Brokers, Consumer Groups
- Producers — acks, batching, compression, idempotent producer, transactions
- Consumers — poll loop, offset commit strategies, rebalancing
- Exactly-once semantics
- Schema Registry + Avro / Protobuf
- Kafka Streams vs Kafka Consumer
- Dead Letter Topics / error handling
- Spring Kafka — @KafkaListener, KafkaTemplate, ConcurrentKafkaListenerContainerFactory
- Kafka vs RabbitMQ — when to choose which
Other Messaging
- RabbitMQ — exchanges, queues, bindings, routing keys
- JMS basics
- Spring AMQP / Spring Kafka integration patterns
Databases (SQL + NoSQL + Search)
Relational (PostgreSQL / MySQL)
- Advanced SQL — joins, subqueries, window functions, CTEs, recursive CTEs
- Indexing — B-tree, Hash, GIN, GiST, composite, covering, partial indexes
- Query optimization — EXPLAIN / EXPLAIN ANALYZE, sequential vs index scan
- Transactions & Isolation levels deep dive
- Locking — row-level, table-level, advisory locks
- Normalization vs Denormalization trade-offs
- Connection pooling — HikariCP internals
- Database migrations — Flyway / Liquibase
- MVCC (Multi-Version Concurrency Control) — how Postgres/MySQL handle it
NoSQL
- MongoDB — documents, collections, aggregation pipeline, indexes
- Redis — data structures (String, Hash, List, Set, Sorted Set, Streams), TTL, pub/sub
- Cassandra / DynamoDB basics (when partition keys matter)
- When to choose SQL vs NoSQL
Search (Elasticsearch / OpenSearch)
- Inverted index — how full-text search works
- Mappings, analyzers, tokenizers
- Search queries — match, term, bool, fuzzy, range
- Aggregations — metric, bucket, pipeline
- Spring Data Elasticsearch integration
- Indexing strategies — bulk indexing, reindexing, aliases
Caching Strategies
Caching Deep Dive
- Cache-aside, Read-through, Write-through, Write-behind, Refresh-ahead
- Cache invalidation strategies — the hard problem
- Spring Cache abstraction — @Cacheable, @CacheEvict, @CachePut, @Caching
- Cache providers — Caffeine (local), Redis (distributed), Ehcache
- TTL vs TTI, eviction policies (LRU, LFU, FIFO)
- Cache stampede / thundering herd — solutions
- Distributed caching consistency challenges
Testing
Unit, Integration, Contract
- JUnit 5 — @Test, @ParameterizedTest, @BeforeEach/@AfterEach, extensions, assertions
- Mockito — @Mock, @InjectMocks, when/thenReturn, verify, ArgumentCaptor, ArgumentMatchers
- @SpringBootTest, @WebMvcTest, @DataJpaTest, @JsonTest, @RestClientTest
- Testcontainers — real databases, Kafka, Redis in tests
- MockMvc, WebTestClient
- @MockBean, @SpyBean
- Contract testing — Spring Cloud Contract / Pact
- Test pyramid vs honeycomb — practical advice
- Mutation testing concepts (PIT)
- What not to mock — over-mocking anti-pattern
- AssertJ — fluent assertions library
- WireMock — external API mocking
- ArchUnit — architecture testing (layer dependencies, naming conventions)
System Design
Fundamentals
- CAP theorem & PACELC
- Consistency models — strong, eventual, causal
- Scalability — vertical vs horizontal, stateless services
- Availability, Latency, Throughput trade-offs
- Load balancing algorithms
- Sharding & Partitioning strategies + hotspots
- Replication — leader-follower, multi-leader, leaderless
- Consistent hashing
- CDNs — how they work, cache invalidation at edge
- DNS resolution and traffic routing
Common System Design Problems
- Design URL Shortener
- Design Rate Limiter
- Design Notification System
- Design Chat / Messaging System
- Design News Feed / Timeline
- Design Search Autocomplete
- Design Distributed Cache
- Design Payment / Order System (with Saga)
- Design Ticket Booking (like BookMyShow) — concurrency control
- Design a Distributed Job Scheduler
- Design a File Storage System (like Google Drive)
Resilience & Observability
Resilience Patterns
- Circuit Breaker (Resilience4j)
- Retry with exponential backoff + jitter
- Bulkhead / Isolation
- Timeout & Fallback
- Rate limiting / Throttling
Observability
- Logging — SLF4J + Logback, structured logging (JSON), MDC for correlation IDs
- Metrics — Micrometer + Prometheus + Grafana
- Distributed Tracing — Micrometer Tracing / OpenTelemetry
- Health checks & readiness/liveness probes
- Alerting strategies
- The three pillars of observability — logs, metrics, traces
Build, Docker, K8s, CI/CD
Build & Dependency Management
- Maven — pom.xml, lifecycle, profiles, multi-module, dependency management
- Gradle — Groovy/Kotlin DSL, task graph, incremental builds
- Dependency conflicts & resolution strategies
Containers & Orchestration
- Docker — Dockerfile best practices for Java (multi-stage, layers, jlink, GraalVM native)
- Docker Compose
- Kubernetes basics — Pods, Deployments, Services, ConfigMaps, Secrets, Ingress, HPA
- Java apps on K8s — memory limits, probes, JVM flags in containers
CI/CD
- Jenkins / GitHub Actions / GitLab CI pipelines
- Blue-Green, Canary, Rolling deployments
- Artifact repositories (Nexus / Artifactory)
- Static analysis (SonarQube), quality gates
Cloud Fundamentals (AWS)
Key AWS Services for Java Backends
- EC2, Security Groups, IAM roles & policies
- S3 — buckets, lifecycle, presigned URLs
- RDS / Aurora — multi-AZ, read replicas
- ElastiCache (Redis/Memcached)
- SQS, SNS, EventBridge
- Lambda + API Gateway (serverless Java considerations — cold starts)
- ECS / EKS / Fargate
- CloudWatch, X-Ray
- AWS SDK for Java v2
- Spring Cloud AWS
Interview Deep Questions
High-Frequency Deep Questions
- How does HashMap work internally? (full explanation with treeification)
- ConcurrentHashMap — how does it achieve thread safety without locking the whole map?
- Explain the Java Memory Model and happens-before
- Difference between synchronized and ReentrantLock
- How does GC decide which objects to collect? (reachability)
- What happens when you call Thread.start() twice?
- Why is String immutable? Benefits and implementation
- Explain Spring Bean lifecycle in detail
- @Transactional propagation and isolation — real scenarios
- How does Spring solve circular dependencies?
- N+1 select problem and all solutions
- Virtual thread pinning — what causes it and how to avoid
- How does CompletableFuture work under the hood?
- Design an LRU Cache (code + concurrency)
- Exactly-once delivery in Kafka — is it possible?
- CAP theorem applied to real systems (Cassandra, Mongo, Postgres)
- How would you debug a memory leak in production?
- Self-invocation problem in Spring AOP / Transactions
- Difference between WebFlux and Virtual Threads approach
- How does ClassLoader hierarchy work and why do we get ClassNotFoundException / NoClassDefFoundError differently?
- Explain OAuth2 Authorization Code flow end-to-end
- How does gRPC achieve better performance than REST?
- What are the trade-offs of GraphQL vs REST for microservices?
🔥 Complete Interview Question Bank (700+ Questions)
Topic 1 — Core Java Fundamentals & OOP (Easy → Hard)
🟢 Easy (Foundation — Must Know for any interview)
- What is Java, and what makes it platform independent?
- How does Java achieve "write once, run anywhere"?
- What are the main features of Java?
- What is the exact difference between JDK, JRE, and JVM?
- What is the difference between primitive types and reference types?
- What is the difference between int, Integer, and autoboxing?
- What is the default value of instance variables?
- What is the difference between local, instance, and static variables?
- What is the scope and lifetime of a variable in Java?
- What are access modifiers, and why do they matter?
- What is the difference between private, protected, package-private, and public?
- What is the difference between final, finally, and finalize()?
- What is the purpose of the main method? What happens when you run a Java class from the command line?
- What is
thiskeyword used for? - What is
superkeyword used for? - What is the difference between
==and.equals()? - What is the use of the
transientkeyword? What aboutvolatile? - What are Access Modifiers in Java? Explain their scope.
- How do you prevent a class from being subclassed?
🟡 Medium (OOP Principles — Heavily Tested)
- Explain the principles of Object-Oriented Programming (OOP). How do you apply them?
- What is polymorphism in Java? (compile-time vs runtime)
- What is encapsulation?
- What is inheritance, and when should you avoid it?
- What is abstraction?
- What is the difference between an interface and an abstract class? What changed in Java 8 and Java 9 regarding interfaces?
- Can an interface extend multiple interfaces? Can a class implement multiple interfaces? How do you resolve default method conflicts?
- Can a class extend more than one class?
- What is the diamond problem, and how does Java handle it?
- Explain Method Overloading vs Method Overriding. Can we override static methods? Can we override private methods?
- What is method hiding vs method overriding?
- What is static vs dynamic binding?
- What is constructor overloading?
- What is the difference between a constructor and a method? Can a constructor be private? Why can't constructors be inherited?
- What is object creation flow in Java? What is the order of initialization?
- What is composition, and how is it different from inheritance?
- What is association, aggregation, and composition?
- Explain Covariant Return Types in Java.
- What is the difference between pass-by-value and pass-by-reference? How does Java handle object references?
- What is a Marker Interface? Give examples (Serializable, Cloneable). How do they work internally?
🔴 Hard (Deep Knowledge — Product-Based Focus)
- Why is String immutable in Java? What are the benefits of this immutability?
- Explain the String Constant Pool (SCP). Where does it reside in memory? What is string interning?
- String vs StringBuilder vs StringBuffer — when to use which? Performance & thread-safety differences.
- How do you create a truly Immutable class in Java? (What if the class contains a mutable object like java.util.Date?)
- Explain the contract between equals() and hashCode(). What happens if you override equals() but not hashCode()?
- How does the clone() method work? Shallow Copy vs Deep Copy in Java — how to implement Deep Copy?
- What is the Object class? What are its methods?
- What is a Memory Leak in Java if Java has a Garbage Collector?
- What are Enums in Java? Can an Enum implement an interface? Can it be instantiated using new?
- How does Java Reflection work? When should you avoid it? What is the relationship between reflection and encapsulation?
- What are Annotations? How do you create a custom Annotation? What is annotation retention and target?
- What is Serialization and Deserialization? What is serialVersionUID? Why is Serializable considered weakly designed?
- Difference between ClassNotFoundException and NoClassDefFoundError?
- What is Type Erasure in Java Generics?
- Explain upper bounds (? extends T) and lower bounds (? super T) in Generics (PECS principle).
- Explain Classloaders in Java (Bootstrap, Extension, Application). Parent delegation model?
- What is the immutable class design pattern?
- Nested classes — static nested, inner, local, anonymous — when to use each?
- What is the difference between core language features and library features in Java?
Topic 2 — Java Collections Framework (Easy → Hard)
🟢 Easy (Foundation)
- What is the Java Collections Framework?
- Explain the Collection hierarchy in Java.
- Collection vs Collections?
- Difference between List, Set, and Map.
- What is the difference between Arrays and Collections?
- What is the Collections utility class used for?
- What is the Deque interface?
🟡 Medium (Internals — Most Asked)
- ArrayList vs LinkedList? When would you choose one over the other?
- How does ArrayList grow dynamically? What is the default capacity and growth factor?
- What is the difference between HashSet, LinkedHashSet, and TreeSet?
- What is the difference between HashMap, LinkedHashMap, and TreeMap?
- HashSet vs TreeSet vs LinkedHashSet? How does HashSet work internally?
- Explain Comparable vs Comparator interfaces. Which one modifies the original class?
- How do you sort a collection using a custom comparator?
- Explain the difference between Iterator and ListIterator.
- What is the difference between Fail-Fast and Fail-Safe iterators? Give examples.
- How does PriorityQueue work internally? (Min-heap / Max-heap)
- What is CopyOnWriteArrayList? When should it be used?
- What is a BlockingQueue? How is it used in Producer-Consumer problems?
- Difference between ArrayBlockingQueue and LinkedBlockingQueue?
- How do you sort a HashMap by values?
- What is the difference between Optional and null? When should Optional be used?
🔴 Hard (Deep Internals — Product-Based Focus)
- Explain the internal working of HashMap. (Hash collision, Buckets, Node array, load factor)
- What changes were made to HashMap in Java 8? (Treeify threshold, O(log n) lookup)
- Why is it recommended to use a power of 2 for HashMap capacity?
- What is a ConcurrentHashMap? How does it differ from Hashtable and Collections.synchronizedMap()?
- Explain the internal working of ConcurrentHashMap (Java 7 Segment locking vs Java 8 CAS & Node locking).
- What is a TreeMap? When would you use it over a HashMap?
- What is WeakHashMap? Provide a use case.
- What is an IdentityHashMap?
- Explain EnumSet and EnumMap. Why are they highly efficient?
- Can we use null as a key in HashMap? What about ConcurrentHashMap? Why?
- What happens if two threads try to modify a HashMap simultaneously?
- Why are HashMap keys typically immutable?
- What is rehashing? When does it happen?
- What is a hash collision and how is it resolved?
Topic 3 — Generics & Type System (Easy → Hard)
🟢 Easy
- What are generics, and why are they useful?
- What is a generic method?
- What is a bounded type parameter?
🟡 Medium
- What is wildcard usage in generics?
- What is the difference between ? extends T and ? super T? (PECS)
- Can you create arrays of generic types? Why not?
- Is List<String> a subclass of List<Object>? (Generics covariance)
🔴 Hard
- What is type erasure? What happens at runtime?
- What are bridge methods generated by the compiler?
- Recursive type bounds (e.g., Comparable<T extends Comparable<T>>)
- Restrictions — no primitives, no instanceof with parameterized types, no arrays of generics
Topic 4 — Exception Handling (Easy → Hard)
🟢 Easy
- What is an exception?
- What is the difference between checked and unchecked exceptions?
- What is the difference between throw and throws?
- What is exception propagation?
- What is the try-catch-finally flow? Can finally be skipped?
- What is a custom exception? When to create one?
- What is the difference between Error and Exception?
- Should you catch Throwable?
🟡 Medium
- When should you use checked exceptions vs unchecked exceptions?
- What is try-with-resources? What problem does AutoCloseable solve?
- What is exception chaining?
- What is the best way to handle exceptions in layered applications?
- Can you have an empty catch block? Why is it bad practice?
🔴 Hard
- What happens if an exception is thrown inside a finally block?
- What happens if you put a return statement inside a finally block?
- Multi-catch, rethrowing with precise types
- Exception wrapping / translation pattern for microservices
Topic 5 — I/O, NIO, Date & Time (Easy → Hard)
🟢 Easy
- What is the difference between BufferedReader and Scanner?
- What is byte stream versus character stream?
- What is the java.time API? Why is java.time better than Date and Calendar?
- What is LocalDate, LocalTime, LocalDateTime?
- What is ZonedDateTime?
- What is Instant?
- What is the difference between Period and Duration?
🟡 Medium
- What is NIO? What is the difference between File and Path?
- What is Path and Files in modern Java I/O?
- What is StringJoiner?
- What is a timezone, and why is it tricky in backend systems?
- What is buffering, and why does it matter?
🔴 Hard
- NIO — Channels, Buffers, Selectors
- What is memory-mapped file access?
- Asynchronous I/O (AsynchronousFileChannel)
Topic 6 — Java 8 to Java 21 Features (Easy → Hard)
🟢 Easy
- What are Lambda Expressions?
- What is a Functional Interface? (Explain @FunctionalInterface)
- What is method reference syntax (::)?
- Explain built-in functional interfaces: Predicate, Function, Supplier, Consumer.
- What is the Optional class? Why was it introduced?
- Optional.orElse() vs Optional.orElseGet()?
- Default and Static methods in interfaces? Why were default methods added?
🟡 Medium
- What is the Streams API? Intermediate vs Terminal operations?
- What is the difference between a collection and a stream?
- What is lazy evaluation in streams?
- Difference between map() and flatMap() in Streams?
- How does reduce() work in Streams?
- What is the difference between findFirst() and findAny()?
- What is collect() used for? Explain Collectors.toMap() pitfalls.
- What is the difference between groupingBy and partitioningBy?
- What is the difference between forEach() and forEachOrdered()?
- How do map, flatMap, filter, and peek differ?
- Explain the new Date and Time API (java.time). Why is java.util.Date deprecated?
- (Java 9) Factory methods for collections (List.of(), Map.of()). Are they mutable?
- (Java 10) What is Local-Variable Type Inference (var)? Where can it NOT be used?
- (Java 11) New String methods (isBlank(), lines(), strip())?
- (Java 14) What are Switch Expressions?
- (Java 15) What are Text Blocks?
🔴 Hard
- Parallel Streams vs Sequential Streams? When should you AVOID parallel streams? What is parallel stream concurrency risk?
- How do Lambda Expressions affect the generated bytecode?
- (Java 9) What is the Java Module System (Project Jigsaw)? Benefits?
- (Java 11) The new HttpClient API?
- (Java 16) What are Records? Can a Record extend a class or implement an interface? What is a compact constructor?
- (Java 17) What are Sealed Classes? How do they aid in Domain-Driven Design?
- (Java 17+) Pattern Matching for instanceof and switch.
- (Java 21) Virtual Threads — How do you create them? How do they differ from Platform Threads?
- (Java 21) Structured Concurrency (Preview) and Scoped Values.
- (Java 21) Sequenced Collections interface.
- What is the difference between sorted() in streams and sorting a collection in place?
Topic 7 — Multithreading & Concurrency (Easy → Advanced)
🟢 Easy
- What is a Thread in Java? What is a Process? Difference between them.
- What is multitasking?
- What is concurrency versus parallelism?
- How do you create a thread in Java? (Thread class vs Runnable interface)
- What is the difference between extending Thread and implementing Runnable?
- Explain the Thread Lifecycle (New, Runnable, Blocked, Waiting, Timed Waiting, Terminated).
- Runnable vs Callable? What is Callable?
- Thread.start() vs Thread.run()?
- What is sleep()? What is yield()? What is join()?
- Thread.sleep() vs Object.wait()?
- What is thread priority?
- What is a Daemon Thread? How is it created?
🟡 Medium
- What is synchronization? What is the purpose of the intrinsic lock / monitor?
- What is a Race Condition? How do you prevent it?
- What is a Deadlock? How do you detect and prevent it?
- Deadlock vs Livelock vs Starvation?
- What is thread safety? What is immutability's role in thread safety?
- What is the synchronized keyword? Difference between synchronized method and synchronized block?
- What is the volatile keyword? Explain the visibility problem and happens-before relationship.
- What guarantees does volatile give? What does volatile NOT guarantee?
- What is atomicity? What is visibility? What is ordering / happens-before?
- What is the Java Memory Model?
- Explain wait(), notify(), and notifyAll(). Why must they be called from a synchronized block?
- Why are wait() and notify() in the Object class, not the Thread class?
- What is interruption? How do you handle InterruptedException properly?
- Explain the Executor Framework. Why is it better than creating raw threads?
- Difference between execute() and submit() in ExecutorService?
- Explain different types of Thread Pools (FixedThreadPool, CachedThreadPool, ScheduledThreadPool, SingleThreadExecutor).
- How do you choose thread pool size?
- What happens when a thread pool queue fills up? What is a rejection policy?
- What is shutdown() vs shutdownNow() in ExecutorService?
- Explain the Future interface. What does Future.get() do?
🔴 Hard
- What is CompletableFuture (Java 8)? How is it different from Future?
- Explain thenApply(), thenAccept(), and thenCompose() in CompletableFuture.
- What is asynchronous composition? What is callback hell?
- What are Atomic classes (AtomicInteger, AtomicReference)? How do they achieve thread safety without synchronization?
- What is CAS (Compare-And-Swap)?
- What is a ReentrantLock? How does it differ from a synchronized block?
- Explain ReadWriteLock. When is it beneficial?
- What is a Semaphore? How does it work?
- What is a CountDownLatch? What is a CyclicBarrier? Difference between them?
- What is a Phaser?
- What is a ThreadLocal? What are its use cases and potential dangers (memory leaks)?
- What is ForkJoinPool? How does work-stealing work?
- Explain the Producer-Consumer problem and write code using wait/notify and BlockingQueue.
- What is double-checked locking? Why was it historically tricky?
- What is context switching? Why is it expensive?
- How does CachedThreadPool work? When can it cause OutOfMemoryError?
- How do you debug a deadlock or high CPU thread issue?
⚫ Advanced (Edge Cases — Senior/Lead Level)
- Can you stop a thread forcefully? Why is Thread.stop() deprecated?
- Explain Spurious Wakeups in threading and how to write loop checks to avoid them.
- What is Lock Coarsening and Lock Elision in the JVM?
- How does LongAdder scale better than AtomicLong under high contention?
- Explain False Sharing in CPU caches. How does @Contended help?
- What is the difference between System.exit(0) and Runtime.getRuntime().halt(0)?
- What is a Shutdown Hook? How do you implement Graceful Shutdown in Java?
- Explain the internal working of ThreadLocalRandom.
- (Java 21) What are Virtual Threads (Project Loom)? How do they differ from Platform Threads?
- How do Virtual Threads change the way we use ThreadLocal? (Scoped Values)
- How does the adoption of Virtual Threads affect Reactive Programming (WebFlux)? Will Reactive die?
- What is Virtual Thread pinning — what causes it and how to avoid it?
Topic 8 — JVM Internals, Memory Management & Garbage Collection (Easy → Advanced)
🟢 Easy
- What is the JVM architecture?
- Heap Memory vs Stack Memory in Java?
- What objects are stored on the stack versus the heap?
- What is garbage collection?
- What is a memory leak in Java?
- What causes OutOfMemoryError?
- What causes StackOverflowError?
🟡 Medium
- Explain the JVM Architecture (Classloader, Runtime Data Areas, Execution Engine).
- What is stored in the Method Area / Metaspace?
- PermGen vs Metaspace (Java 8 change)? Why was it changed?
- What is the Program Counter (PC) Register?
- How does the Garbage Collector work in Java?
- Explain the Generational Garbage Collection model (Young Gen, Old/Tenured Gen).
- Eden Space vs Survivor Spaces (S0, S1)?
- Minor GC vs Major GC vs Full GC?
- What are GC Roots? How does Mark-and-Sweep work?
- What is object reachability?
- What is a strong reference? Soft reference? Weak reference? Phantom reference?
- What is "Stop-the-World" (STW) pause?
- How do you trigger Garbage Collection manually? (Is System.gc() guaranteed?)
- Explain the flags -Xmx and -Xms.
- What causes java.lang.OutOfMemoryError: Java heap space?
- What causes java.lang.OutOfMemoryError: Metaspace?
🔴 Hard
- Explain different Types of GC: Serial, Parallel, CMS, G1 GC, ZGC, Shenandoah.
- How does G1 GC work? Why is it default in newer Java versions?
- What is ZGC? What are its latency promises?
- How do you profile a Java application? (JConsole, VisualVM, Java Mission Control).
- What is a Heap Dump? How do you generate and analyze it?
- What is JIT (Just-In-Time) compilation? Explain C1 and C2 compilers. What is the difference between interpretation and compilation?
- What is Escape Analysis in JVM?
- What is String Deduplication in G1 GC?
- Explain happens-before guarantee in JVM memory model.
- What is compressed oops?
- What is the class loading process? What are the phases of class loading?
- What is the parent delegation model?
- What is the difference between Class.forName() and ClassLoader.loadClass()?
- What is static initialization? What is the use of static blocks?
- What is the difference between class loading and class initialization?
- What are JIT compilation and bytecode?
⚫ Advanced (JVM Tuning — Senior/Architect Level)
- What is the -XX:+PrintGCDetails flag?
- Explain TLAB (Thread-Local Allocation Buffer). Why is it used?
- What is PLAB (Promotion Local Allocation Buffer)?
- What are JVM Safepoints? Why do they impact performance?
- How do you tune the JVM for a high-throughput vs a low-latency application?
- What is the difference between intrinsic locks and JNI (Java Native Interface)?
- What is GraalVM? How does Ahead-Of-Time (AOT) compilation differ from JIT?
- What are Native Images? (Spring Native). Pros and cons?
- What is the jlink tool? How do you create a custom minimal JRE?
- What is the Foreign Function & Memory API (Project Panama)?
Topic 9 — Spring Framework & Spring Boot Core (Easy → Advanced)
🟢 Easy
- What is the Spring Framework?
- Difference between Spring and Spring Boot? Why is Spring Boot used on top of Spring?
- What is Inversion of Control (IoC) and Dependency Injection (DI)?
- What is constructor injection? Setter injection? Field injection — why is it discouraged?
- What is a Spring bean?
- What is the Spring application context?
- What is @Component, @Service, @Repository, and @Controller?
- What is component scanning?
- What is @Configuration? What is @Bean?
- What is the difference between @Component and @Bean?
- What is auto-wiring?
🟡 Medium
- What is the ApplicationContext? Difference between ApplicationContext and BeanFactory?
- Explain the Spring Bean Lifecycle.
- What are the Spring Bean Scopes? (Singleton, Prototype, Request, Session, Application, WebSocket)
- What happens if there are multiple beans of the same type?
- What is @Primary and @Qualifier?
- @Controller vs @RestController?
- @RequestMapping vs @GetMapping?
- @RequestParam vs @PathVariable?
- @Component vs @Service vs @Repository vs @Controller? What is a stereotype annotation?
- What does @SpringBootApplication do internally? (Break down the 3 annotations)
- How does Spring Boot Auto-Configuration work? (@EnableAutoConfiguration, spring.factories / AutoConfiguration.imports)
- What is the Spring Boot starter concept?
- What are conditional beans?
- What is @ControllerAdvice? How do you implement Global Exception Handling?
- Explain Filter vs Interceptor in Spring. When to use which?
- How do you externalize configuration in Spring Boot? (application.properties, .yml, environment variables)
- Explain Spring Profiles. How do you load profile-specific properties?
- Difference between @Value and @ConfigurationProperties?
- What is the difference between application.properties and application.yml?
- What is the difference between application.properties and environment variables?
- What is Spring Boot Actuator? Name some critical endpoints (/health, /metrics, /heapdump).
- How do you secure Actuator endpoints?
- What is readiness versus liveness?
- How do you handle CORS in Spring Boot?
- How does Spring Boot handle Embedded Servers (Tomcat, Jetty, Undertow)? How to switch?
- What is the role of DispatcherServlet?
- How do you schedule tasks in Spring Boot? (@Scheduled, Cron expressions)
- How do you run logic at application startup? (CommandLineRunner, ApplicationRunner, @EventListener)
- What is the bootstrapping sequence of a Spring Boot app?
- What is the difference between JAR and WAR deployment?
- What is externalized config in production?
- How do you manage secrets safely?
🔴 Hard
- How do you inject a Prototype bean into a Singleton bean? (Explain @Lookup)
- How does Spring AOP work? (Aspect, Advice, Pointcut, JoinPoint, Weaving)
- JDK Dynamic Proxies vs CGLIB Proxies in Spring AOP?
- How does @Transactional work internally?
- Explain @Transactional Propagation levels (REQUIRED, REQUIRES_NEW, NESTED, etc.).
- Explain @Transactional Isolation levels (READ_UNCOMMITTED, READ_COMMITTED, REPEATABLE_READ, SERIALIZABLE).
- Why does self-invocation of an @Transactional method not start a transaction?
- What is rollback behavior in Spring transactions? Rollback rule configuration?
- What is Spring WebFlux? How does it differ from Spring MVC?
- Reactor Core: Mono vs Flux?
- What is the difference between before, after, after-returning, after-throwing, and around advice?
- What is the difference between declarative and programmatic transaction management?
- What are common mistakes in Spring Boot projects?
- What makes a Spring Boot app production-ready?
⚫ Advanced (Spring Internals — Architect Level)
- How does Spring resolve Circular Dependencies? (3-level cache / ObjectFactory). Why not supported by default in newer Spring Boot?
- Explain the Proxy mechanism in Spring. When does self-invocation bypass the proxy?
- How do you implement a Custom Scope in Spring?
- What is MethodReplacer in Spring?
- Explain Spring's TransactionSynchronizationManager.
- What is Spring Boot 3 AOT compilation?
- Why did Spring Boot 3 migrate from javax.* to jakarta.* packages?
- What makes a Spring application hard to test?
Topic 10 — Spring Data JPA & Hibernate (Easy → Advanced)
🟢 Easy
- What is ORM?
- What is JPA? What is Hibernate? Difference between JPA and Hibernate?
- Difference between JPA, Hibernate, and Spring Data JPA?
- What is an Entity? Explain @Entity, @Id, @GeneratedValue, and @Table.
- What is lazy loading? What is eager loading?
- What is a repository in Spring Data JPA?
🟡 Medium
- Explain the Entity Lifecycle states (Transient, Managed, Detached, Removed).
- How does the EntityManager work? What is the persistence context?
- What is the difference between persist, merge, find, and remove?
- save() vs saveAndFlush() in Spring Data JPA?
- findById() vs getById() / getReferenceById()? (Eager vs Lazy evaluation)
- Explain Fetch Types: FetchType.LAZY vs FetchType.EAGER. Which is the default for different associations?
- Explain Cascade Types (ALL, PERSIST, MERGE, REMOVE). CascadeType.REMOVE vs orphanRemoval=true?
- How do you map relationships: One-to-One, One-to-Many, Many-to-One, Many-to-Many?
- What is the owning side of a relationship? (Explain mappedBy). What is a join table?
- What is JPQL? How does it differ from SQL and native SQL?
- How do you execute native SQL queries in Spring Data JPA?
- What is dirty checking in Hibernate?
- What is cascading? What is orphan removal?
- When should you use DTOs instead of entities in APIs?
- What is a transaction boundary in a service layer?
- What does @Transactional actually do? Why does self-invocation break @Transactional?
- What is propagation REQUIRED? What is propagation REQUIRES_NEW?
🔴 Hard
- What is the N+1 Select Problem? How do you solve it? (Join Fetch, Entity Graphs, @BatchSize)
- What is @EntityGraph?
- Explain the difference between First Level Cache and Second Level Cache in Hibernate.
- How do you configure a Second Level Cache? (Ehcache, Redis)
- What is Query Cache?
- Explain Optimistic Locking vs Pessimistic Locking.
- How do you implement Optimistic Locking in JPA? (@Version). What happens if OptimisticLockException is thrown?
- What is Auditing in Spring Data JPA? (@CreatedBy, @CreatedDate, @LastModifiedDate)
- How do you manage database schema migrations? (Flyway, Liquibase)
- What is @MappedSuperclass? Difference from JOINED inheritance?
- How do you use Projections in Spring Data JPA to optimize queries?
- Why should you avoid using Lombok @Data, @EqualsAndHashCode, and @ToString with JPA Entities?
- How does Connection Pooling work? (HikariCP specifics)
- What are common ORM performance mistakes?
⚫ Advanced
- Hibernate: Explain Session vs StatelessSession. When to use StatelessSession?
- How do you handle Multiple DataSources in a single Spring Boot application?
- How do you implement Distributed Transactions using JTA (Java Transaction API) and Atomikos?
- What is Bytecode Enhancement in Hibernate? (Lazy loading for basic attributes)
- What is @DynamicUpdate and @DynamicInsert annotation in Hibernate?
Topic 11 — Database, SQL & NoSQL (Easy → Advanced)
🟢 Easy
- What is a relational database? What is SQL?
- What is a primary key? Foreign key? Unique constraint?
- What is a transaction? What are ACID properties? Explain each.
- What is the difference between DELETE, TRUNCATE, and DROP?
- WHERE vs HAVING clause?
- UNION vs UNION ALL?
- What is an index? How do indexes improve reads and hurt writes?
- What is a join? Explain INNER, LEFT, RIGHT, FULL, CROSS, Self Join.
- What is a subquery? What is a correlated subquery?
- What is aggregation in SQL? What is GROUP BY? What is HAVING?
- What is normalization? What is denormalization? When to denormalize?
🟡 Medium
- Explain Transaction Isolation Levels and anomalies (Dirty Read, Non-repeatable read, Phantom read).
- What are Database Indexes? How do they work internally? (B-Trees, B+ Trees)
- Clustered Index vs Non-Clustered Index?
- What is a Composite Index? Does the order of columns matter? (Leftmost prefix rule)
- What happens to performance if there are too many indexes on a table?
- What is an index scan versus full table scan?
- How do you optimize a slow database query? (Explain EXPLAIN / EXPLAIN ANALYZE)
- Explain Database Normalization: 1NF, 2NF, 3NF, BCNF.
- What are Stored Procedures, Functions, and Triggers? Should business logic be in the DB?
- What is a View? What is a Materialized View?
- How does database Pagination work? (OFFSET/LIMIT vs Keyset/Cursor Pagination). Why is OFFSET slow?
- SQL vs NoSQL. When to choose which?
- What is connection pooling? Why is a connection pool important?
- What is pessimistic locking? Optimistic locking? Lost update?
- What is deadlock in the database?
- What is transaction rollback? Commit? Savepoint?
🔴 Hard
- Explain the CAP Theorem. Which two can a Relational DB provide? Which two does Cassandra/MongoDB provide?
- What is PACELC theorem?
- MongoDB: Document structure? _id field?
- How does Replication work in MongoDB (Replica sets)?
- What is Sharding in MongoDB? Explain Shard Key selection.
- Cassandra: How does data partitioning work? (Consistent hashing). What are Tombstones?
- What is Eventual Consistency vs Strong Consistency?
- How do you handle concurrent updates in a database?
- What is a Database Connection Leak?
- Explain the concept of Write-Ahead Logging (WAL).
- What is Database Partitioning (Horizontal vs Vertical)?
- Explain Master-Slave architecture. How do you handle read-heavy systems?
⚫ Advanced
- Explain MVCC (Multi-Version Concurrency Control) in PostgreSQL/MySQL.
- What is Gap Locking in InnoDB?
- How do you troubleshoot high I/O wait times on a database server?
- Explain Geo-spatial queries in MongoDB vs PostgreSQL (PostGIS).
- How do you model data for reporting vs transactions?
Topic 12 — Caching & Redis (Easy → Advanced)
🟢 Easy
- Why do we need Caching?
- What caching strategies do you know?
- What is LRU cache?
- Redis vs Memcached?
🟡 Medium
- Explain Cache Eviction Policies (LRU, LFU, FIFO). How to implement LRU in Java? (LinkedHashMap)
- Cache Aside vs Write-Through vs Write-Behind vs Write-Around?
- Explain Redis Data Structures (Strings, Hashes, Lists, Sets, Sorted Sets).
- Where would you use a Redis Sorted Set? (Leaderboards)
- What is Redis Pub/Sub? How is it different from Kafka/RabbitMQ?
- How does Redis handle persistence? (RDB vs AOF)
- Is Redis single-threaded? If yes, why is it so fast?
- How do you use Spring Cache? (@Cacheable, @CachePut, @CacheEvict)
- What is cache invalidation?
🔴 Hard
- What is Cache Stampede (Thundering Herd)? How do you prevent it?
- What is Cache Penetration? How to solve it? (Bloom Filters)
- What is Cache Breakdown? What is Cache Avalanche? Solution?
- Explain Redis Cluster and Data Sharding.
- How to implement distributed locking using Redis? (Redlock algorithm)
- How do you handle hot keys?
⚫ Advanced
- Redis: What is a Redis Pipeline? Why use it over multiple commands?
- Redis: Explain Lua scripting in Redis. Why is it useful for atomicity?
- Redis: What is the HyperLogLog data structure used for?
- Redis memory is full. What happens? (Explain maxmemory-policy)
- Your Redis cache node dies. What is the impact on the DB, and how does Sentinel/Cluster handle it?
Topic 13 — Messaging & Event-Driven Architecture (Easy → Advanced)
🟢 Easy
- Synchronous vs Asynchronous Communication?
- What is a message broker?
- What is pub-sub?
- What is event-driven architecture?
- What is Kafka used for in microservices?
- What is RabbitMQ used for in microservices?
- RabbitMQ vs Apache Kafka? When to use which?
🟡 Medium
- Explain RabbitMQ concepts: Exchange, Queue, Binding, Routing Key.
- Explain RabbitMQ Exchange types (Direct, Topic, Fanout, Headers).
- Explain Kafka Architecture: Brokers, Topics, Partitions, Replicas.
- What is the role of Zookeeper / KRaft in Kafka?
- How does Kafka scale? (Partitions)
- Explain Kafka Consumer Groups. What happens if consumers > partitions?
- How does Kafka guarantee message ordering? (Within a partition)
- What is the offset in Kafka? How is it committed? (Auto vs Manual commit)
- Explain Delivery Guarantees: At-most-once, At-least-once, Exactly-once.
- What is a Dead Letter Queue (DLQ)? How do you handle failed messages?
- What are Kafka Producers? What is the acks configuration (acks=0, acks=1, acks=all)?
- What is backpressure?
🔴 Hard
- How to achieve Exactly-once semantics in Kafka?
- What is Kafka Log Retention? What is Log Compaction?
- How do you handle Consumer Lag in Kafka?
- What is a Kafka Rebalance? When does it happen?
- How to handle poison pill messages in Kafka/RabbitMQ?
⚫ Advanced
- What is the difference between Event Notification, Event-Carried State Transfer, and Event Sourcing?
- Kafka: What happens when a consumer group receives a new member? (Rebalance protocol, Sticky Assignor)
- Kafka: Explain max.poll.records and max.poll.interval.ms. What happens if processing takes too long?
- Kafka Transactions: How does Kafka achieve read-committed isolation for exact-once processing?
- RabbitMQ: What is a quorum queue? How does it differ from a mirrored queue?
Topic 14 — REST API Design, gRPC & GraphQL (Easy → Hard)
🟢 Easy
- What is HTTP? What does it mean that HTTP is stateless?
- What are common HTTP methods? Which are safe? Which are idempotent?
- What is the difference between GET, POST, PUT, PATCH, and DELETE?
- PUT vs PATCH? POST vs PUT?
- What makes an HTTP method Idempotent? Which methods are idempotent?
- What is REST? What are its guiding principles?
- What is JSON? What is serialization format choice in APIs?
- What is the difference between URI and URL?
- What status codes should a backend developer know? (200, 201, 204, 400, 401, 403, 404, 409, 422, 429, 500)
🟡 Medium
- Explain Richardson Maturity Model for REST APIs.
- How do you design REST APIs for a resource with relations? (e.g., GET /users/{id}/orders)
- How do you handle API Versioning? (URI, Query param, Header, Content Negotiation)
- What are the best practices for REST API status codes?
- What are the rules for proper REST API URI naming? (Nouns, plurals, lowercase)
- What is pagination? Cursor pagination versus offset pagination?
- What is filtering and sorting in APIs?
- What is a good REST resource design?
- What is content negotiation? What are HTTP headers used for?
- What is caching in HTTP? What are ETags? Explain HTTP caching headers (Cache-Control, ETag, Last-Modified).
- What is HATEOAS?
- What is request validation? What is response shape consistency?
- What is error contract design?
- What is correlation ID propagation?
- What is backward compatibility in APIs? What causes API brittleness?
- What is rate limiting at API layer?
- What is API gateway vs reverse proxy?
- How to secure a REST API?
🔴 Hard
- What is GraphQL? How does it solve Over-fetching and Under-fetching?
- GraphQL queries vs mutations vs subscriptions?
- What is the N+1 problem in GraphQL? (DataLoader solution)
- What are the trade-offs of GraphQL vs REST for microservices?
- What is gRPC? How is it different from REST? How does gRPC achieve better performance?
- Explain Protocol Buffers (Protobuf). Why are they faster than JSON?
- Streaming in gRPC (Unary, Server-streaming, Client-streaming, Bi-directional).
- gRPC: How do you implement interceptors in gRPC for logging or auth?
- WebSockets vs Server-Sent Events (SSE) vs Long Polling?
- What is SSE and how do you implement it in Spring Boot?
- How does RSocket differ from HTTP/REST?
Topic 15 — Spring Security, Authentication & Authorization (Easy → Hard)
🟢 Easy
- What is Spring Security?
- Authentication vs Authorization?
- What is session-based authentication? What is token-based authentication?
- What is role-based access control? What is authority versus role?
- Why should passwords never be stored in plain text?
🟡 Medium
- Explain Spring Security Architecture. (DelegatingFilterProxy, FilterChain, AuthenticationManager, ProviderManager)
- What is a security filter chain? What is the role of filters in security?
- What is UserDetails and UserDetailsService in Spring Security?
- What is AuthenticationManager? What is SecurityContext?
- What is a JWT (JSON Web Token)? Explain its structure (Header, Payload, Signature).
- Is JWT encrypted or encoded? Can the client read the payload?
- What is inside a JWT? What is the difference between access token and refresh token?
- Where should you store a JWT on the client side? (Local Storage vs HttpOnly Cookies)
- JWT vs Session-based authentication?
- What is stateless security?
- How do you secure endpoints in Spring Security?
- What is method-level security? @PreAuthorize and @Secured?
- Explain Role-Based Access Control (RBAC) vs Attribute-Based Access Control (ABAC).
- Password Hashing: Why use BCrypt over MD5/SHA? What is a Salt? What is password encoding?
- What is CSRF (Cross-Site Request Forgery)? How to prevent it? Why is CSRF not a big issue with stateless JWTs?
- What is CORS (Cross-Origin Resource Sharing)? Preflight request (OPTIONS)?
- What is XSS (Cross-Site Scripting)? How to prevent it in Java?
- How do you prevent SQL Injection? (Prepared Statements)
- How do you secure REST APIs differently from web apps?
🔴 Hard
- What is OAuth 2.0? Explain its components (Resource Owner, Client, Authorization Server, Resource Server).
- Explain OAuth2 Grant Types: Authorization Code, Client Credentials, Implicit, Password. Which one is for server-to-server?
- What is the authorization code flow? What is client credentials flow?
- What is password flow, and why is it discouraged?
- What is OpenID Connect (OIDC)? Difference from OAuth2?
- How do you invalidate/revoke a JWT before it expires? (Token blacklisting). What is token revocation?
- Why is exposing JWT in logs dangerous?
- What is the security impact of weak CORS configuration?
- What is the difference between secure and insecure defaults?
- What are common Spring Security interview traps?
- What is AnonymousAuthenticationFilter?
⚫ Advanced
- What is Mutual TLS (mTLS)? How is it used in a Service Mesh?
- How does OAuth2 PKCE flow work? Why is it safer than Implicit flow?
- What is a JWKS (JSON Web Key Set)? How does a resource server validate a token from an auth server?
- How do you manage secrets in the cloud? (AWS Secrets Manager, HashiCorp Vault)
- How do you implement Zero-Trust Network Architecture in microservices?
Topic 16 — Microservices & Distributed Systems (Easy → Advanced)
🟢 Easy
- What is a monolith? What is a microservice?
- Monolithic vs Microservices architecture? Pros and Cons.
- Why do companies move from monolith to microservices? When is microservices a bad idea?
- How do microservices communicate? (Synchronous REST/gRPC vs Asynchronous Messaging)
- What is the difference between REST and messaging?
- What is synchronous communication? What is asynchronous communication?
🟡 Medium
- What is an API Gateway? What are its responsibilities? (Routing, Rate Limiting, Authentication). Spring Cloud Gateway?
- What is Service Discovery? (Netflix Eureka, Consul, K8s DNS). Client-side vs Server-side discovery?
- Client-side vs Server-side Load Balancing? (Ribbon/Spring Cloud LoadBalancer)
- What is the Circuit Breaker Pattern? Why is it needed? (Resilience4j). Explain the 3 states (Closed, Open, Half-Open).
- What is the Bulkhead pattern? Rate Limiter? Retry pattern? Timeout handling? Fallback?
- What is retry, and when can it make things worse?
- What is throttling?
- How do you implement Distributed Tracing? (Sleuth, Zipkin, OpenTelemetry, TraceID, SpanID)
- How do you handle Distributed Logging? (ELK/EFK Stack, Splunk). Log correlation?
- What is metrics versus logs versus traces?
- What are SLIs, SLOs, and SLAs?
- How do you manage configurations across multiple microservices? (Spring Cloud Config, HashiCorp Consul/Vault)
- What is centralized configuration? What is Spring Cloud used for?
- What is the difference between Spring Cloud and Spring Boot?
- How do you ensure Idempotency in REST APIs and Message Listeners? Why is idempotency important for retries?
- How do you manage database per service? Can one service query another service's database? What is shared database anti-pattern?
- How do you handle backward compatibility in APIs? (API Versioning)
- How do you handle Authentication in Microservices? (JWT passed from Gateway, OAuth2)
🔴 Hard
- How do you decompose a Monolith into Microservices? (Strangler Fig Pattern, Domain-Driven Design)
- What is Domain-Driven Design (DDD)? (Bounded Context, Aggregate, Ubiquitous Language)
- Explain Distributed Transactions. Why is 2-Phase Commit (2PC) bad for microservices?
- What is the Saga Pattern? (Choreography vs Orchestration)
- What is the Outbox Pattern? How does it solve the dual-write problem?
- What is CQRS (Command Query Responsibility Segregation)? When should you use it?
- What is Event Sourcing? How does it relate to CQRS?
- What is Eventual Consistency? What is eventual consistency trade-off in product systems?
- What is a Service Mesh? (Istio, Linkerd). How is it different from an API Gateway?
- What is the Sidecar pattern?
- Describe zero-downtime deployment strategies (Blue-Green, Canary, Rolling updates).
- What is the BFF (Backend for Frontend) Pattern?
- How to prevent the "Thundering Herd" problem?
- How do you debug a production outage across services?
- How do you handle distributed transactions?
Topic 17 — System Design: HLD & LLD (Easy → Advanced)
🟢 Easy (Design Principles)
- What are the SOLID Principles? Explain each with Java examples.
- What is DRY, KISS, and YAGNI?
- How do you gather requirements for a system design problem?
- How do you estimate traffic and storage?
- How do you think about scalability, latency, and throughput?
🟡 Medium (Design Patterns)
- Explain Creational Patterns: Singleton (Double-checked locking), Factory vs Abstract Factory, Builder, Prototype.
- Explain Structural Patterns: Adapter, Facade, Decorator, Proxy.
- Explain Behavioral Patterns: Strategy, Observer, Command, Chain of Responsibility.
- How do you decide between SQL and NoSQL?
- How do you decide between monolith and microservices?
- Load Balancing Strategies: Round Robin, Least Connections, IP Hash.
- What is horizontal scaling? Vertical scaling?
- What is sticky session, and why is it risky?
- What is replication? What is sharding? What is partitioning?
- What is CDN? What is the role of a Content Delivery Network?
- What is object storage versus block storage?
- Active-Active vs Active-Passive failover?
- Single Point of Failure (SPOF) — How to identify and eliminate?
🔴 Hard (HLD Problems — Product-Based Focus)
- How would you design a Rate Limiter? (Token Bucket, Leaky Bucket, Sliding Window algorithms)
- How would you design a URL Shortener (like bit.ly)? (Base62 encoding, KGS)
- How would you design a Notification System? (Email, SMS, Push)
- How would you design a Chat Application (WhatsApp/Messenger)? (WebSockets, XMPP, Message ordering)
- How would you design an E-commerce system (Amazon/Flipkart)?
- How would you design a highly scalable Payment Gateway? (Idempotency, 2-phase commit, ACID)
- How would you design a ride-hailing service (Uber/Ola)? (Quadtrees, Geohashing)
- How would you design a Streaming Service (Netflix/YouTube)? (CDN, transcoding, adaptive bitrate)
- How would you design an upload/download service?
- How would you design a job scheduler?
- How would you design a feed/timeline system?
- How would you design a search system?
- How would you design a payment flow safely?
- How do you scale a system from 100 to 1,000,000 users?
- How do you design for high availability? Fault tolerance? Disaster recovery?
- Explain Consistent Hashing. Where is it used?
- How do you design for exactly-once semantics? Is exactly-once really possible end to end?
- How do you make systems resilient to retries? How do you prevent duplicate processing?
- How do you handle distributed locks? When to use ZooKeeper, Redis locks, or database locks?
- How do you design observability into a system? Audit logging?
- How do you design multi-tenancy? Tenant isolation?
- How do you handle GDPR-like deletion requirements?
- How do you evolve architecture without breaking production?
- How do you choose synchronous versus asynchronous boundaries?
🟡 LLD Problems (Low-Level Design)
- LLD: Design a Parking Lot (Classes, Interfaces, Design Patterns)
- LLD: Design a Vending Machine
- LLD: Design an ATM System
- LLD: Design a Library Management System
- LLD: Design a Movie Ticket Booking System (BookMyShow) — Concurrency handling for seats
- LLD: Design an LRU Cache (code + concurrency)
⚫ Advanced (System Design Components)
- How do you design a distributed ID generator? (Twitter Snowflake, UUID, DB auto-increment)
- How does a Bloom Filter work? What is its false-positive rate?
- What is a Merkle Tree? Where is it used in distributed systems?
- What is a Distributed Hash Table (DHT)?
- Explain the Gossip Protocol.
- Raft vs Paxos Consensus Algorithms? (Leader election basics)
- How do you design an autocomplete/typeahead system? (Trie data structure)
- How do you implement rate limiting in a distributed cluster without centralized Redis?
- What is rate-based admission control?
- How do you handle hot partitions?
Topic 18 — DevOps, Docker, Kubernetes & CI/CD (Easy → Hard)
🟢 Easy
- What is Docker? Image vs Container?
- What is Docker Compose?
- What is Kubernetes (K8s)?
- What is a CI/CD Pipeline? (Jenkins, GitLab CI, GitHub Actions)
- Explain Git workflow (GitFlow vs Trunk-based development).
🟡 Medium
- Dockerfile instructions: CMD vs ENTRYPOINT? ADD vs COPY?
- What are Docker image layers? How do you optimize a Dockerfile for a Spring Boot app? (Multi-stage builds, Jib)
- K8s Master and Worker Nodes components?
- Explain K8s Pods, Deployments, ReplicaSets.
- Explain K8s Services (ClusterIP, NodePort, LoadBalancer).
- What is an Ingress Controller?
- ConfigMaps and Secrets in Kubernetes?
- How do you configure Liveness and Readiness probes for a Spring Boot app in K8s?
- Blue-Green, Canary, Rolling deployments.
- Artifact repositories (Nexus / Artifactory).
- What is SonarQube? Code coverage vs Code quality?
- What is a Git Rebase vs Git Merge? When do you squash commits?
🔴 Hard
- Java apps on K8s — memory limits, probes, JVM flags in containers.
- What is a Canary Release vs Dark Launching?
- How do you use Feature Toggles (Feature Flags) effectively? (Unleash, LaunchDarkly)
- Explain "Shift-Left" testing in CI/CD.
Topic 19 — Testing & Quality (Easy → Hard)
🟢 Easy
- What is unit testing versus integration testing?
- What is Mockito used for?
- What is the difference between mock, spy, and stub?
- What is the purpose of Spring Boot tests?
🟡 Medium
- JUnit 4 vs JUnit 5 architecture?
- Mockito: @Mock vs @InjectMocks vs @Spy?
- How do you mock static methods? (Mockito inline)
- How do you mock a database call when testing a Service class?
- What is @SpringBootTest? What is @WebMvcTest? What is @DataJpaTest?
- What is test slice in Spring Boot?
- What is the difference between @MockBean and @Mock?
- What should you not test with mocks?
- How do you test exception scenarios?
- How do you test transactional methods?
- How do you test repository layer behavior?
- How do you write maintainable unit tests? Tests for edge cases?
- How do you write tests for concurrency bugs?
- How do you choose between using an in-memory DB and Testcontainers?
🔴 Hard
- What are Testcontainers? Why are they better than in-memory DBs (H2) for Integration Testing?
- TDD (Test-Driven Development) vs BDD (Behavior-Driven Development) (Cucumber)?
- Explain contract testing (Spring Cloud Contract / Pact).
- What is the value of contract tests?
- What makes a Spring application hard to test?
Topic 20 — Cloud, Observability & Tooling (Easy → Hard)
🟢 Easy
- AWS/Cloud: SQS vs SNS? When to use which?
- What is the significance of logging levels?
- Why is structured logging useful?
- What is the role of correlation IDs?
🟡 Medium
- What is the RED method for monitoring? (Rate, Errors, Duration)
- What is the USE method? (Utilization, Saturation, Errors)
- How do you structure logs for a log aggregator like Splunk/ELK? (JSON logging, MDC)
- What is a Reverse Proxy vs Forward Proxy? (Nginx)
- Explain standard HTTP caching headers (Cache-Control, ETag, Last-Modified).
🔴 Hard
- Explain serverless computing (AWS Lambda). Cold start problem in Java?
- How do you handle Webhooks safely? (Signature verification, retry policies)
- Explain what a "Data Mesh" is compared to a "Data Lake".
Topic 21 — Data Structures & Problem Solving (Product-Based Focus)
🟡 Core DS/Algo Concepts (Must practice coding)
- String Manipulation: Reverse string, Anagrams, Longest Palindromic Substring.
- Arrays: Two Sum, Kadane's Algorithm (Max Subarray), Merge Intervals, Trapping Rain Water.
- Linked Lists: Reverse a LL, Detect cycle (Floyd's algorithm), Merge two sorted lists, Find middle node.
- Stacks/Queues: Valid Parentheses, Next Greater Element, LRU Cache implementation, Implement Queue using Stacks.
- Trees: BST validations, Inorder/Preorder/Postorder traversals, LCA, Level Order Traversal, Max depth/diameter.
- Graphs: BFS vs DFS, Cycle detection, Dijkstra's Algorithm, Topological Sort (Course Schedule).
- Hashing: Group Anagrams, Top K Frequent Elements.
- Sorting & Searching: Binary Search, Merge Sort, Quick Sort time complexities. Find element in rotated sorted array.
- Dynamic Programming: Climbing Stairs, Coin Change, Longest Increasing Subsequence, Knapsack 0/1.
- Two Pointers / Sliding Window: Longest Substring Without Repeating Characters, Max Consecutive Ones.
- Heaps: Find Kth largest element in an array, Merge K sorted lists.
- Time & Space Complexity calculations (Big O notation) for all the above.
Topic 22 — Tricky, Rapid-Fire & Logic Questions (Most Asked in Interviews)
- Why does 1.0 / 0.0 give Infinity but 1 / 0 gives ArithmeticException?
- What will System.out.println(0.1 + 0.2 == 0.3) output and why? (IEEE 754 floating point)
- Why do you use BigDecimal for currency instead of double?
- Can you have an empty catch block? Why is it bad practice?
- Can you override a static method to make it non-static?
- Is List<String> a subclass of List<Object>? (Generics covariance)
- What happens if you put a return statement inside a finally block?
- How do you break out of nested loops in Java? (Labeled breaks)
- What is the StrictMath class? strictfp keyword?
- Why isn't String an array of characters?
- Can you use
thisinside a static method? - What is var handles or modern low-level alternatives at a high level?
- What is the difference between JRE memory errors and database memory issues?
Topic 23 — Spring Boot REST, Validation & Configuration (Medium → Hard)
- How do you create REST endpoints in Spring Boot?
- What is @RestController? Difference between @Controller and @RestController?
- What is @RequestMapping? Difference between @GetMapping, @PostMapping, @PutMapping, @DeleteMapping?
- What is request parameter binding? Path variable binding? Request body binding?
- What is @ResponseStatus? What is ResponseEntity?
- What is the best way to design error responses?
- What is global exception handling with @ControllerAdvice?
- What is validation in Spring Boot? What is Bean Validation?
- What is @Valid? What is @Validated?
- How do you handle partial updates?
- What is property binding? What is @ConfigurationProperties?
- What is the difference between @Value and configuration properties?
- What is Spring Boot actuator? Which actuator endpoints are commonly used?
- What should and should not be exposed by actuator?
- What is health check?
- How do you configure profiles for dev, test, and prod?
- How do you handle versioning in REST APIs?
Topic 24 — Architecture Patterns (Medium → Hard)
- Explain Hexagonal Architecture (Ports and Adapters). How does it differ from Layered Architecture?
- Clean Architecture: What belongs in the Core/Domain layer?
- Why should DTOs (Data Transfer Objects) be separated from Entities?
- Do you map DTOs manually or use libraries? (MapStruct vs ModelMapper). Why is MapStruct preferred?
- How to manage large data exports (e.g., generating a 1M row CSV) without OOM? (Streaming cursors, pagination)
- What happens if your server clock drifts? How does it affect OAuth tokens and Distributed systems? (NTP)
- You inherit a massive, messy legacy monolithic codebase. How do you safely refactor it?
- How do you decide what belongs in controller, service, and repository?
- How do you decide what should be synchronous versus async in a feature?
- How do you keep a codebase readable as it grows?
- How do you review someone else's backend code?
- How do you prioritize correctness, speed, and maintainability?
Topic 25 — Scenario-Based & Troubleshooting (3.8 YoE Focus)
🟡 Production Debugging Scenarios
- Scenario: Your Spring Boot application is consuming 100% CPU in production. How do you debug and resolve this?
- Scenario: Production logs show frequent OutOfMemoryError. How do you identify the root cause? (Heap dump analysis, Eclipse MAT)
- Scenario: An API that normally takes 50ms is suddenly taking 5 seconds. Step-by-step troubleshooting?
- How do you debug a NullPointerException in production?
- How do you debug a memory leak?
- How do you debug slow API response times?
- How do you debug a deadlock?
- How do you debug high CPU usage?
- How do you debug an intermittent test failure?
- How do you debug a database timeout?
- How do you debug a transaction rollback issue?
🔴 Architecture & Resilience Scenarios
- Scenario: A user reports payment was deducted but order was not placed. How do you handle this? (Saga, Reconciliation)
- Scenario: How do you perform a database schema alteration on a 50GB table in production without downtime?
- Scenario: A batch job processing 10 million records nightly is failing. How to optimize? (Spring Batch, chunk processing)
- Scenario: Your application needs to call a third-party API that fails randomly. How to ensure resilience?
- Scenario: How do you handle API security when two internal microservices talk to each other?
- Scenario: The database is experiencing high number of deadlocks. How do you resolve this?
- Scenario: A Kafka consumer is failing on a message and is stuck in a loop. How to design around it?
- Scenario: You deploy a new microservice version and everything crashes. Explain rollback strategy.
- How do you handle a production bug when logs are incomplete?
- How do you handle a bad deployment? How do you roll back safely?
- How do you design safe migrations for schema changes?
Topic 26 — Behavioral & Career Questions (Must Prepare for 3.8 YoE)
- What is the most challenging technical problem you solved in your current project?
- Tell me about the toughest backend problem you solved.
- Describe a time you disagreed with a Senior or Architect on a design choice. How did you resolve it?
- How do you ensure code quality in your team? (Code reviews, static analysis)
- Tell me about a time you broke production. What happened and how did you fix it?
- Why did you choose Java and Spring for your project?
- What performance issue did you actually measure?
- What would you refactor in your current project?
- Where is your code over-engineered?
- Where is your code under-designed?
- How do you explain a trade-off you made in design?
- How do you answer "why should we hire you" for a backend role?
- How do you handle a question you do not know in interview?
- If you have 3.8 years of experience, what technical implementation are you most proud of, and how did you measure its success?
Topic 27 — Deep Systems, Resiliency & The Final Frontier (Advanced)
- In a 2PC (Two-Phase Commit), what happens if the coordinator crashes after the "prepare" phase?
- How do you achieve true High Availability (HA) across multiple geographical regions? (Active-Active global DBs like Spanner/Cockroach)
- Explain Chaos Engineering (e.g., Chaos Monkey). Why inject failures in production?
- How to scale WebSockets? (Pub/Sub backplane with Redis/Kafka)
- What is the "Split-Brain" problem in distributed clusters (Elasticsearch, Zookeeper), and how do quorums solve it?
- How do you implement Zero-Trust Network Architecture in microservices?
- Your Redis cache node dies. What is the impact on the DB, and how does Sentinel/Cluster handle it?
Topic 28 — Latest Trends & Modern Java Ecosystem (2024-2026)
- How do Virtual Threads change the way we use ThreadLocal? (Scoped Values)
- How does the adoption of Virtual Threads affect Reactive Programming (WebFlux)? Will Reactive die?
- What is the jlink tool? How do you create a custom minimal JRE?
- What is Spring Boot 3 AOT compilation?
- Why did Spring Boot 3 migrate from javax.* to jakarta.* packages?
- What is the Foreign Function & Memory API (Project Panama)?
- Explain what a "Data Mesh" is compared to a "Data Lake".
- How do you handle Webhooks safely? (Signature verification, retry policies)
- What is SSE (Server-Sent Events) and how do you implement it in Spring Boot?
- How does RSocket differ from HTTP/REST?
- (Java 21) Structured Concurrency and Scoped Values.
- (Java 21) Sequenced Collections interface.
Study Advice
- Be ready to go deep on any topic you list on your resume.
- Prefer explaining trade-offs over memorizing definitions.
- Write clean code on the spot — practice on a whiteboard or simple editor.
- System Design + Deep Java (Concurrency/JVM/Collections) + Spring internals is the winning combination.
- Keep a personal notes repo with code snippets and diagrams for each hard topic.
This roadmap is intentionally exhaustive. You don't need to master every subtopic to the same depth, but awareness of the full landscape helps you answer follow-up questions confidently.