Top 500 Java Backend Interview FAQs
1. Explain the difference between == and .equals() in Java.
2. Why is String immutable in Java?
3. What is the difference between HashMap and ConcurrentHashMap?
a
4. Explain the concept of fail-fast vs fail-safe iterators.
5. What is the significance of hashCode() and equals() method?
al
6. How does ArrayList work internally?
7. What is the difference between ArrayList and LinkedList?
8. How does Java handle memory management?
9. What is the role of the final keyword?
10.
w
How does Garbage Collection work in Java?
11. What is a WeakHashMap?
de
12. How is synchronization achieved in Java?
13. What are the different thread states?
14. What is the difference between Runnable and Callable?
15. What is thread starvation?
16. What is the difference between wait(), sleep(), and yield()?
Ko
17. How does the volatile keyword work?
18. What is a race condition? How to prevent it?
19. Explain ReentrantLock vs synchronized block.
20. What is thread pooling and how is it implemented?
21. What is the Fork/Join framework?
22. Explain Stream API with examples.
23. Difference between map() and flatMap() in Streams?
24. What are functional interfaces?
25. What is the difference between Optional.of() and Optional.ofNullable()?
26. What is method reference? Give examples.
27. How does Collectors.groupingBy() work?
28. What is the default method in interfaces?
29. What are sealed classes in Java?
30. What is a record class in Java?
31. Difference between checked and unchecked exceptions.
a
32. Custom exception handling in real-world applications.
33. What is the diamond problem in Java?
al
34. How does autoboxing/unboxing work?
35. Explain Enum in Java.
36. When to use TreeMap vs HashMap?
37.
38.
w
Why should hashCode() be consistent with equals()?
How to make an object immutable?
39. What is the use of transient keyword?
de
40. What is reflection in Java?
41. What is the difference between static and instance initialization block?
42. Difference between shallow copy and deep copy.
43. What is the use of System.identityHashCode()?
44. Explain CompletableFuture with example.
Ko
45. How do you implement a singleton pattern?
46. What are some ways to break a singleton?
47. What is double-checked locking?
48. What are phantom references?
49. Why is clone() considered bad practice?
50. How would you design your own custom collection?
51. Explain method overloading vs overriding.
52. Explain covariant return types.
53. How does Java handle pass-by-value or reference?
54. Can we override private/static/final methods?
55. When would you use an abstract class over interface?
56. What is java.lang.instrument used for?
57. What is Metaspace in Java?
58. How to detect memory leaks in Java?
59. What is ClassLoader? Types of class loaders?
a
60. What is JIT compiler?
61. How do annotations work internally?
al
62. How to create custom annotations?
63. What is annotation processing in Java?
64. What are lambdas and how do they work internally?
65.
66.
w
Explain Type Erasure in Generics.
How are Generics implemented internally?
67. Explain bounded vs unbounded wildcards.
de
68. What is raw type in Java?
69. How would you make a list thread-safe?
70. How to avoid deadlock in concurrent programming?
71. Difference between Spring and Spring Boot.
72. What is dependency injection and how is it implemented in Spring?
Ko
73. Difference between @Component, @Service, @Repository, and @Controller.
74. What is the role of @Autowired and how does it work?
75. How does Spring Boot auto-configuration work?
76. What are the starter dependencies in Spring Boot?
77. What is @SpringBootApplication composed of?
78. How does component scanning work in Spring Boot?
79. How do profiles work in Spring Boot?
80. What are beans in Spring? Lifecycle?
81. Difference between ApplicationContext and BeanFactory.
82. How to define a custom scope?
83. What is AOP? Explain with use-case.
84. Difference between cross-cutting concern and business logic?
85. How to implement custom annotations with AOP?
86. What is the use of @Transactional?
87. What is the difference between programmatic and declarative transaction
a
management?
88. Explain propagation types in transaction management.
89. How does Spring handle circular dependency?
al
90. What is the difference between @Value, @ConfigurationProperties, and
Environment?
91. Explain RestTemplate vs WebClient.
92.
93.
w
What is reactive programming in Spring?
Difference between Mono and Flux?
94. What is Spring WebFlux?
de
95. How to secure a REST API using Spring Security?
96. Difference between permitAll() and authenticated()?
97. What is CSRF and how to handle it in Spring?
98. What is AuthenticationManager?
Ko
99. How to implement custom authentication in Spring Security?
100. What are filters and interceptors?
101. What is the difference between Filter and HandlerInterceptor?
102. How does Spring handle exceptions?
103. What is the difference between @ControllerAdvice and @ExceptionHandler?
104. How to return consistent error responses in Spring REST?
105. How to create custom validators in Spring Boot?
106. Difference between validation groups and constraints?
107. What is the use of @Valid and @Validated?
108. How to use Swagger/OpenAPI in Spring Boot?
109. Difference between @PathVariable and @RequestParam.
110. What is HATEOAS?
111. How does @Async work in Spring Boot?
112. What is Spring Scheduler? Cron jobs?
113. How to publish and listen to events in Spring?
114. Difference between synchronous and asynchronous event publishing.
a
115. How does caching work in Spring Boot?
116. How to use Redis for caching?
al
117. How to monitor Spring Boot applications?
118. What are Spring Boot Actuators?
119. How to expose custom metrics?
w
120. How to configure a datasource manually?
121. What is Spring Data JPA?
122. What are derived query methods?
de
123. Difference between CrudRepository, JpaRepository, PagingAndSortingRepository.
124. How to handle pagination in Spring Data?
125. What is query-by-example (QBE)?
126. How to write native queries in JPA?
127. Difference between EntityManager and JdbcTemplate.
Ko
128. What is @EntityGraph?
129. What is lazy vs eager loading?
130. How does dirty checking work in JPA?
131. What is the N+1 select problem? Solution?
132. Difference between optimistic and pessimistic locking.
133. What is @DynamicUpdate in Hibernate?
134. How does @Inheritance work in JPA?
135. What is a DTO? Why is it used?
136. How to map DTO to Entity and vice versa?
137. What is ModelMapper?
138. What are common performance pitfalls in Spring Boot applications?
139. How to use Spring Boot with Docker?
140. How to externalize configurations in Spring Boot?
141. What is Spring Config Server?
142. Difference between Spring Cloud Config and application.yml?
a
143. How to use Spring Cloud with Eureka?
144. What is a circuit breaker in Spring Cloud?
al
145. What is Spring Cloud Gateway? Difference with Zuul?
146. How to write filters in Spring Gateway?
147. What is Resilience4j and how is it integrated?
w
148. What is Sleuth and Zipkin? How do they work?
149. What is Spring Retry?
150. What are distributed transactions and how to manage them in Spring?
de
151. What is Saga Pattern?
152. How to implement service discovery?
153. Difference between Ribbon and Spring Cloud LoadBalancer?
154. What is Hystrix? Why is it deprecated?
155. What is FeignClient and how does it work?
Ko
156. Difference between OpenFeign and RestTemplate?
157. How does OAuth2 work with Spring Security?
158. What is JWT? How is it integrated with Spring Boot?
159. How to secure microservices with API Gateway?
160. What is Spring Session?
161. How to implement rate limiting in Spring Boot?
162. What is service registry and how does it help?
163. How to trace a request across multiple services?
164. How to implement custom starter in Spring Boot?
165. How to test Spring Boot applications?
166. What is MockMvc and when to use it?
167. How to mock external services in integration tests?
168. What is @DataJpaTest?
169. What is TestContainers and how to use with Spring Boot?
170. What is the difference between Unit Test and Integration Test in Spring?
a
171. How is a microservice different from a monolith?
172. What are the advantages and disadvantages of microservices?
al
173. How do microservices communicate?
174. What is service discovery?
175. What is Eureka and how does it work?
w
176. What is API Gateway in microservices?
177. How does Spring Cloud Gateway work?
178. What are edge services?
de
179. Explain the importance of bounded contexts in microservices.
180. What is domain-driven design (DDD)?
181. What is the difference between orchestration and choreography in microservices?
182. What is a distributed transaction?
183. How do you achieve eventual consistency?
Ko
184. Explain the Saga pattern with example.
185. How would you handle inter-service communication failures?
186. What is circuit breaker pattern?
187. How does Resilience4j work?
188. What is rate limiting? How do you implement it?
189. How to design idempotent APIs?
190. What is a fallback method in circuit breaker?
191. What is load balancing? Types?
192. Difference between client-side and server-side load balancing.
193. What is Ribbon? Is it still used?
194. What is Spring Cloud LoadBalancer?
195. What is API versioning and how to implement it?
196. How to secure microservices using OAuth2?
197. What is JWT? How to use it in microservices?
198. What is token propagation?
a
199. How do you handle secrets in microservices?
200. What is config server?
al
201. How to refresh config without restarting services?
202. What is bootstrap.yml vs application.yml?
203. What is centralized logging?
w
204. How does distributed tracing work?
205. What is Sleuth? What is Zipkin?
206. What are span and trace IDs?
de
207. What is an anti-corruption layer?
208. What is the database-per-service pattern?
209. What are shared-nothing architectures?
210. What is CQRS? When to use it?
211. What is Event Sourcing?
Ko
212. What is a sidecar pattern?
213. What is service mesh? What tools are used?
214. What is Istio and Linkerd?
215. How do you monitor microservices?
216. What is Prometheus and Grafana?
217. What are metrics and observability?
218. What is health check API?
219. How to perform health checks in Spring Boot?
220. How do you debug issues in a distributed environment?
221. What are dead-letter queues?
222. How do you manage service versioning?
223. How to maintain backward compatibility?
224. How do you deploy multiple microservices together?
225. What is blue-green deployment?
226. What is canary deployment?
a
227. How to rollback a faulty microservice?
228. What are the common microservices pitfalls?
al
229. How would you refactor a monolith into microservices?
230. What is a shared library in microservices?
231. What is API composition?
w
232. What is service granularity?
233. How do you manage dependencies between microservices?
234. How to test microservices independently?
de
235. What is consumer-driven contract testing?
236. What is Pact and how does it work?
237. How do you handle timeouts in microservices?
238. What is asynchronous communication?
239. When to use synchronous vs asynchronous communication?
Ko
240. What is eventual consistency vs strong consistency?
241. How to handle large payloads in microservices?
242. How to implement file upload in a microservice?
243. What is throttling?
244. How do you scale a microservice?
245. What is horizontal vs vertical scaling?
246. What is container orchestration?
247. How does Kubernetes support microservices?
248. What is the difference between microservices and SOA?
249. What is a backend-for-frontend (BFF) pattern?
250. What is the role of a message broker in microservices?
251. What are the best practices for microservice architecture?
252. What is a service mesh used for?
253. Explain the Ambassador pattern in microservices.
254. What are the 12 factors of microservices?
a
255. What is polyglot persistence?
256. What is observability and why is it critical?
al
257. How do you ensure microservices are resilient?
258. What’s the difference between telemetry, tracing, and logging?
259. What is shadow traffic?
w
260. How do you handle API deprecation in microservices?
261. How do you build a microservice SDK?
262. What is the difference between REST and gRPC?
de
263. How do you integrate GraphQL in microservices?
264. What is a lightweight vs heavyweight service?
265. What is head-of-line blocking?
266. What is a correlation ID and how is it useful?
267. How to design authentication in a microservice ecosystem?
Ko
268. What is the strangler pattern in microservices migration?
269. Explain real-world microservice monitoring setup using Spring Boot + Sleuth + Zipkin +
Prometheus + Grafana.
270. What is the difference between WHERE and HAVING?
271. What is indexing? How does it improve performance?
272. What is a composite index?
273. What are clustered and non-clustered indexes?
274. What is normalization? Types?
275. What is denormalization?
276. What is ACID property?
277. What is the difference between TRUNCATE, DELETE and DROP?
278. What are window functions? Examples?
279. What is CTE?
280. How does GROUP BY work internally?
281. What is query optimization?
a
282. How to analyze slow queries?
283. What is a transaction isolation level?
al
284. Explain deadlocks in SQL and how to resolve.
285. What are stored procedures? Pros/Cons?
286. How do you handle migrations in production DB?
w
287. How do ORMs like Hibernate work?
288. What is Hibernate’s first-level cache?
289. What is the difference between save(), persist(), merge() and update()?
de
290. What is the difference between get() and load()?
291. What is lazy initialization exception?
292. What is the purpose of @JoinColumn and @OneToMany?
293. How to handle orphan removal?
294. How does Hibernate manage object states?
Ko
295. What are common Hibernate performance issues?
296. How does the second-level cache work in Hibernate?
297. Difference between Criteria API and JPQL?
298. What is flush() and clear()?
299. What is a natively generated ID vs sequence?
300. What is optimistic locking in JPA?
301. How to implement soft delete in Hibernate?
302. How does MongoDB store data?
303. Difference between MongoDB and MySQL?
304. What are documents and collections?
305. How to model one-to-many relationship in MongoDB?
306. What is aggregation framework in MongoDB?
307. What is sharding?
308. What are indexes in MongoDB?
309. How does Redis work?
a
310. What is TTL in Redis?
311. Difference between Redis and Memcached?
al
312. What are common use cases of Redis?
313. How to store sessions in Redis?
314. What is persistence in Redis?
w
315. How does Redis pub/sub work?
316. What are Redis data types?
317. How to avoid cache stampede?
de
318. How does cache eviction work in Redis?
319. What is write-through vs write-behind cache?
320. When would you use NoSQL over SQL?
353. What is CI/CD? Explain the flow.
354. What tools are used in CI/CD?
Ko
355. Difference between Jenkins, GitHub Actions, and GitLab CI?
356. How to automate Spring Boot builds with Maven and Jenkins?
357. What is a Jenkins pipeline?
358. What is the difference between scripted and declarative pipeline?
359. How do you trigger builds automatically on git push?
360. What is the use of .gitlab-ci.yml or .github/workflows?
361. What is artifact management? Use of Nexus/Artifactory?
362. How do you perform zero-downtime deployments?
363. What is a rollback deployment strategy?
364. How do you manage secrets in CI/CD?
365. How do you deploy a Spring Boot app using Jenkins?
366. What is blue-green deployment? How to implement it?
367. What are stages in a pipeline?
368. How to run integration tests during a pipeline?
369. How to deploy microservices to Kubernetes using CI/CD?
a
370. What is infrastructure as code?
371. How do you use Terraform in CI/CD?
al
372. What is Ansible and how does it compare with Chef/Puppet?
373. What is Helm and how is it used?
374. What is GitOps?
w
375. How do you manage environment-specific configuration in CI/CD?
376. What is a canary release?
377. What are Docker images and how are they pushed in CI/CD?
de
378. How do you tag Docker images automatically?
379. What is build caching?
380. What is a webhook?
381. How do you monitor CI/CD pipelines?
382. What is the use of a staging environment?
Ko
383. How to use SonarQube in your CI pipeline?
384. How to ensure code quality and security before deployment?
385. What are test, build, deploy, and post-deploy hooks?
386. What is Docker? Why is it used?
387. What is the difference between a container and an image?
388. What is a Dockerfile? Common instructions?
389. How to build and run a Docker image?
390. How to connect containers using Docker network?
391. What is a Docker volume?
392. How do you pass environment variables to a container?
393. What is Docker Compose?
394. How do you containerize a Spring Boot application?
395. How to optimize Docker image size?
396. What is the difference between ENTRYPOINT and CMD?
397. What is a multi-stage build in Docker?
a
398. How to persist logs in a Docker container?
399. What are Docker health checks?
al
400. What is the role of .dockerignore?
401. What is Apache Kafka?
402. How does Kafka work internally?
w
403. What is a Kafka topic and partition?
404. Difference between Kafka consumer groups and individual consumers?
405. How do you ensure message ordering in Kafka?
de
406. What is the role of Kafka brokers and zookeepers?
407. How to consume messages from Kafka using Spring Boot?
408. What is Kafka offset? How is it managed?
409. What is the difference between at-most-once, at-least-once, and exactly-once delivery?
410. How do you handle backpressure in Kafka consumers?
Ko
411. Design an Aadhaar Registration System (like UIDAI).
412. Design a UPI transaction system.
413. Design a URL shortener like Bitly.
414. Design a rate limiter service.
415. Design an email notification system.
416. Design a payment gateway like Razorpay.
417. Design an order management system.
418. Design a social media platform like Twitter.
419. Design a ride-sharing app backend like Uber.
420. Design a cab allocation algorithm.
421. Design a stock trading system.
422. Design a distributed caching system.
423. Design a scalable file storage service like Dropbox.
424. Design a newsfeed algorithm like Facebook.
425. Design a job scheduler system.
a
426. Design an e-commerce checkout system.
427. Design a multi-tenant SaaS app.
al
428. Design a chat messaging system.
429. Design a calendar booking system.
430. Design a scalable search engine.
w
431. Design a log aggregation system.
432. Design a fraud detection system for bank transactions.
433. Design a real-time bidding system.
de
434. Design a student registration portal for an academy.
435. Design a document approval workflow.
436. Design a notification aggregator.
437. Design an online exam portal.
438. Design a microservice for user identity management.
Ko
439. Design a task scheduling system.
440. Design a content moderation system.
441. Design an IoT telemetry processing service.
442. Design a language translation service.
443. Design a product catalog service.
444. Design a document versioning service.
445. Design a survey application.
446. Design a hotel booking system.
447. Design a cloud storage system.
448. Design a recommendation engine.
449. Design an OTP verification system.
450. Design a distributed rate limiter using Redis.
451. What is scalability? Vertical vs Horizontal?
452. What is latency vs throughput?
453. What is availability? What is reliability?
a
454. What is eventual consistency?
455. What is a CAP theorem?
al
456. What is partition tolerance?
457. What is sharding?
458. What is replication? Master-slave vs multi-master?
w
459. What is quorum in distributed systems?
460. What is a leader election?
461. What are consistent hashing and its use?
de
462. What is cache invalidation?
463. How to handle cache synchronization across nodes?
464. What is a load balancer? How does it work?
465. What is sticky session?
466. What is a CDN? How does it improve performance?
Ko
467. What are API rate limits and why needed?
468. What is message deduplication?
469. What is idempotency?
470. What is a distributed lock?
471. What is a bloom filter?
472. What is a write-ahead log (WAL)?
473. What are eventual vs strong consistency tradeoffs?
474. What is data partitioning?
475. What is circuit breaker pattern in system design?
476. What is the backpressure mechanism?
477. What is dead letter queue (DLQ)?
478. What is rolling update vs blue-green deployment?
479. What is a health check and readiness probe?
480. What is service mesh and when to use it?
481. What is gRPC and when is it better than REST?
a
482. What is API Gateway and what are its roles?
483. How do you ensure observability in distributed systems?
al
484. What are retries and exponential backoff?
485. How to achieve fault tolerance in microservices?
486. How to horizontally scale a database?
w
487. What is an outbox pattern?
488. What is eventual consistency using Kafka?
489. How to maintain ACID in distributed systems?
de
490. What is data deduplication?
491. What are shadow writes and reads?
492. What is a quorum write/read?
493. What are the tradeoffs of NoSQL vs SQL?
494. How do you scale a notification service?
Ko
495. What is system resiliency?
496. What are retries vs compensation?
497. What is a read replica? When to use it?
498. How do you implement distributed tracing?
499. What is service orchestration vs choreography?
500. How do you handle schema evolution in microservices?