Java Spring Boot – SSE-II Offline Drive
Question Set
(Backend + Database + System Design + DSA)
Backend-Focused Questions (Spring Boot
+ Java Ecosystem)
1. Explain Filters, Interceptors, and AOP Advice in Spring Boot.
Give real-world use cases and clearly differentiate where each fits in the request
lifecycle.
2. When exactly do you choose Filter vs HandlerInterceptor vs AOP?
Draw the exact execution pipeline for a Spring MVC request.
3. Explain SOLID principles with Java-centric examples (Spring Beans, Services,
Repositories).
4. Walk through how dependency injection works in Spring.
How does the container resolve beans? Explain bean scopes (singleton,
prototype, request/session scope).
5. Repository Pattern vs JPA Query Methods vs JPQL vs Native SQL — when do you
choose which?
6. Explain optimistic locking vs pessimistic locking in Hibernate.
Which one is better for high-contention write-heavy systems?
7. How do you implement scheduled jobs and distributed background workers in Spring?
(ScheduledExecutor, Spring Scheduler, Quartz, Kafka consumers)
8. API versioning in Spring Boot — (URI, header-based, content-negotiation). Which scales
best long-term?
9. Explain distributed caching with Spring Cache + Redis.
How do you design cache invalidation for a multi-instance deployment?
10.What is eventual consistency? Give a Spring/Kafka-based scenario where it is preferred
over strict consistency.
11.Explain the Saga Pattern and how it would be implemented in Java using Kafka/Outbox
pattern.
12.Modular monolith vs microservices in Spring.
How do module boundaries change? What about shared DTOs vs independent
bounded contexts?
13.What is an idempotent API?
Show how to implement an idempotent POST using database constraints or Redis
locks.
14.Explain complete lifecycle of a Spring Boot request:
Filter → Interceptor → Controller → Service → Repository → ExceptionHandler.
15.Explain how Hibernate’s MVCC works internally.
How does it enable high concurrency?
16.What are ACID properties?
How does PostgreSQL ensure them under concurrent writes with Spring Data JPA in
play?
17.How do you analyze slow queries in Java/Hibernate?
How do you interpret EXPLAIN ANALYZE and Hibernate logs?
18.When do you prefer partial indexes, covering indexes, composite indexes?
19.Explain transaction behavior under READ COMMITTED vs REPEATABLE READ with
Spring @Transactional.
20.Design an audit logging system using JPA events + database triggers.
What are the pros/cons of each?
21.SSE vs WebSockets vs Long Polling — exact differences in Java (Spring WebFlux or
Servlet stack).
22.Explain how Redis Pub/Sub or Kafka helps scale WebSocket events across multiple
pods.
23.How do you authenticate WebSocket connections securely in Spring?
24.What problems arise when broadcasting large payloads to thousands of clients?
How to mitigate memory pressure?
25.Implement role-based + permission-based authorization using Spring Security.
How do you create custom annotations like @HasPermission()?
26.Design a global exception handler using @ControllerAdvice for consistent API
responses.
27.Explain common Java backend security vulnerabilities (XXE, SSRF, JWT misuse,
deserialization attacks).
28.How do you store API secrets securely in Java?
(Vault, AWS SM, encrypted environment configs)
29.Explain refresh token rotation and preventing replay attacks in Spring Security.
30.Design a resilient API integration layer using Resilience4j (retry, circuit breaker, fallback).
31.Redis cache vs in-memory cache (Caffeine) in multi-node Spring Boot clusters.
Explain correctness issues.
32.How do you design a job queue with retries, DLQ, delay scheduling in Java?
(Kafka, RabbitMQ, custom scheduler)
33.How do you design cache invalidation for create/update/delete flows?
34.How do you prevent thread starvation when a downstream API is slow or rate-limited?
35.Explain how Kubernetes HPA scales Java workloads using CPU/memory/custom
metrics.
36.During rolling deployments, what problems arise with schema mismatches?
How do you prevent them?
37.How do you design a blue-green or canary deployment pipeline for Java apps?
38.Importance of liveness/readiness/startup probes for Spring Boot containers.
39.How do you generate typed API clients in Java + React?
(OpenAPI/Swagger Codegen)
40.How do React Suspense / Server Components reduce backend load?
Explain from a Java API design perspective.
41.How do you optimize large list endpoints?
Pagination, cursor-based pagination, projections, DTO slicing.
42.How to avoid over-fetching/under-fetching in complex React + Spring APIs?
(GraphQL vs REST vs selective DTOs)
Database Design Use-Cases 1. OAuth2 / SSO Identity
Service
● Ask the candidate to design a multi-provider SSO system supporting Google, GitHub, etc.
They must model user identities, sessions, and token lifecycles.
● Tables Expected: users, providers, identities, refresh tokens, sessions.
● Query to ask after DB design: List all active Google sessions for users who signed in last
14 days.
● Sample Answer:
SELECT s.*
FROM sessions s
JOIN identities i ON s.identity_id = [Link]
JOIN providers p ON i.provider_id = [Link]
JOIN users u ON i.user_id = [Link]
WHERE [Link] = 'google'
AND s.is_active = TRUE
AND u.last_login_at >= NOW() - INTERVAL '14 days';
2. Short Link Platform with Analytics
● Candidate should design a Bitly-style shortener with click tracking, geo metadata, and device
analytics. Schema should consider high-read, high-write workloads.
● Tables Expected: links, redirects, geo events, device meta.
● Query to ask after DB design: Top 5 countries for a link in the past 7 days.
● Sample Answer:
SELECT [Link], COUNT(*) AS clicks
FROM geo_events ge
WHERE ge.link_id = $1
AND ge.created_at >= NOW() - INTERVAL '7 days'
GROUP BY [Link]
ORDER BY clicks DESC
LIMIT 5;
3. Feature Flags / Experimentation
● Design a scalable experimentation system that assigns users to variants, stores rules, and
supports gradual rollouts.
● Tables Expected: flags, variants, rules, assignments.
● Query: Variant distribution for each active flag.
● Sample Answer:
SELECT [Link] AS flag_name,
[Link] AS variant_name,
COUNT(a.user_id) AS user_count
FROM flags f
JOIN variants v ON v.flag_id = [Link]
LEFT JOIN assignments a ON a.variant_id = [Link]
WHERE f.is_active = TRUE
GROUP BY [Link], [Link]
ORDER BY [Link], [Link];
4. SaaS Billing (Subscriptions + Usage Metering)
● Design tables for tenants, subscription plans, usage logs, billing cycles, invoice generation,
and payments.
● Tables Expected: tenants, subscriptions, usage, invoices.
● Query: MRR by tenant for the current month.
● Sample Answer:
SELECT [Link] AS tenant_id,
SUM([Link]) AS mrr
FROM tenants t
JOIN subscriptions s ON s.tenant_id = [Link]
JOIN invoices i ON i.subscription_id = [Link]
WHERE DATE_TRUNC('month', i.created_at) = DATE_TRUNC('month', NOW())
GROUP BY [Link];
5. Retryable Distributed Job Queue
● Model a resilient job processing system with retries, delayed jobs, attempt logs, and a
dead-letter queue.
● Tables Expected: jobs, attempts, schedules, dlq.
● Query: Jobs that failed >3 times in the last 24 hours.
● Sample Answer:
SELECT [Link],
COUNT([Link]) AS failed_attempts
FROM jobs j
JOIN attempts a ON a.job_id = [Link]
WHERE [Link] = 'failed'
AND a.created_at >= NOW() - INTERVAL '24 hours'
GROUP BY [Link]
HAVING COUNT([Link]) > 3;
6. Notification Delivery System (Multi-channel: Email, SMS, Push)
● Design a system supporting various notification channels, user preferences, delivery tracking,
and retry logic.
● Tables Expected: users, notifications, channels, delivery_attempts, provider_responses.
● Query: Users who failed to receive >3 SMS notifications in last 48 hours.
● Sample Answer:
SELECT [Link] AS user_id
FROM users u
JOIN notifications n ON n.user_id = [Link]
JOIN channels c ON n.channel_id = [Link]
JOIN delivery_attempts da ON da.notification_id = [Link]
WHERE [Link] = 'sms'
AND [Link] = 'failed'
AND da.created_at >= NOW() - INTERVAL '48 hours'
GROUP BY [Link]
HAVING COUNT([Link]) > 3;
DSA Questions (Java solutions)
1. Longest substring without repeating characters (sliding window).
2. Minimum size subarray sum ≥ target (two pointers).
3. Rotate array right by K (in-place reversal).
4. Check if one string is a rotation of another.
5. Optimized anagram check (character array count).
6. Merge two sorted arrays without extra space.
7. Find all anagrams of a pattern in a string (sliding window).
8. Longest palindromic substring (expand around center / DP).
Java Streams & Collectors Questions
1. Grouping + Aggregation (Real Backend Scenario)
Given a list of Transaction objects, write a Streams pipeline to:
● filter only SUCCESS transactions
● group by accountNo
● compute total credit and total debit separately
● return a Map<String, AccountSummary>
Explain pitfalls: null fields, negative values, rounding, BigDecimal vs double, concurrency.
2. map() vs flatMap() — Practical Backend Example
Explain the difference between map() and flatMap()
with real examples such as:
● flattening nested DTOs ([Link]().stream())
● mapping entities to response DTOs
● flattening tags from multiple products
3. Handling Duplicate Keys in toMap()
What happens when [Link]() receives duplicate keys?
Rewrite with:
● merge function
● and choosing between HashMap, LinkedHashMap, and TreeMap.
4. Parallel Streams — When They Are Worse
Explain why parallel streams can be slower than sequential streams:
● ForkJoinPool overhead
● shared mutable state
● IO-bound operations
● false sharing
● ORDERED streams becoming bottlenecks
Give a real backend example where parallel streams are harmful.
5. Employee Highest Salary Per Department (Max + Grouping)
Write a Streams pipeline to group employees by department and return
the highest-salary employee per department.
Avoid unsafe [Link]() and return a clean DTO.
6. Custom Collector Using [Link]()
Implement a custom collector to compute average salary:
● accumulator
● combiner
● finisher
Explain why you may prefer this over [Link]() in
performance-critical code.
7. List of High Earners (> Average Salary) Using Streams
Using Streams only:
● compute org-wide average salary (efficiently, without multiple passes)
● return employees whose salary > average
Explain pitfalls: overflow, numeric precision, repeated iteration.