Spring Boot MCQs

Spring Boot MCQs (Quiz)

October 6th, 2026
191
30:00 Minutes

Preparing for a Spring Boot interview or Java development role? This collection of Spring Boot MCQs is a practical resource for testing your knowledge of Spring Boot fundamentals, auto-configuration, dependency injection, REST APIs, validation, Spring Data JPA, transactions, security, Actuator, testing, caching, messaging, microservices, scheduling, deployment, and real-world Spring Boot scenarios.

Note: Score 60% or higher to unlock an exclusive offer of up to 50% off on self-paced Spring Boot courses.

Let’s begin!

Spring Boot Fundamentals

1. What is Spring Boot primarily designed to do?






2. Which annotation is commonly used on a Spring Boot application entry class?






3. What does @SpringBootApplication combine?






4. What is Spring Boot auto-configuration intended to provide?






5. What is a Spring Boot starter?






6. Which embedded server is commonly used by Spring Boot web applications by default with the servlet stack?






7. What is the main benefit of an embedded server?






8. Which command commonly runs a Maven-based Spring Boot application?






9. What does SpringApplication.run typically do?






10. Which packaging style is commonly used for a deployable Spring Boot application?






Spring Boot Project Configuration

11. Which file is commonly used for Spring Boot configuration in YAML format?






12. Which property sets the HTTP server port?






13. What is the purpose of application.properties?






14. What does Spring Boot support for externalized configuration?






15. What is a profile in Spring?






16. Which property activates a Spring profile?






17. What is @Value commonly used for?






18. What is @ConfigurationProperties useful for?






19. Why should secrets generally not be hard-coded in application.properties committed to source control?






20. What does configuration precedence help determine?






Dependency Injection and IoC

21. What is dependency injection?






22. What does IoC mean in Spring?






23. Which annotation commonly marks a class as a service component?






24. Which annotation commonly marks a repository component?






25. Which annotation is commonly used for a generic Spring-managed component?






26. What is constructor injection?






27. Why is constructor injection often preferred for required dependencies?






28. What happens when multiple beans match a dependency and no disambiguation exists?






29. Which annotation can designate a preferred bean when multiple candidates exist?






30. Which annotation can select a specific bean by qualifier?






Bean Lifecycle and Scopes

31. What is a Spring bean?






32. What is the default Spring bean scope?






33. What does prototype scope mean?






34. Which annotation can define a bean-producing method inside a configuration class?






35. What is @PostConstruct commonly used for?






36. What is @PreDestroy commonly used for?






37. What does bean lazy initialization mean?






38. Which property enables lazy initialization globally?






39. What is a circular dependency?






40. Why can circular dependencies be problematic?






Web and REST APIs

41. Which annotation is commonly used for a REST controller?






42. What does @GetMapping map?






43. What does @PostMapping map?






44. What does @PathVariable bind?






45. What does @RequestParam commonly bind?






46. What does @RequestBody typically do?






47. What does ResponseEntity allow a controller to control?






48. Which HTTP status commonly represents successful resource creation?






49. Which annotation can define a base path for controller methods?






50. What is content negotiation?






Validation and Exception Handling

51. Which annotation is commonly used to validate a request object in a controller?






52. What is Bean Validation used for?






53. Which annotation commonly requires a string to contain non-whitespace characters?






54. Which annotation commonly requires a numeric value to be within a range?






55. What is @ControllerAdvice commonly used for?






56. What does @ExceptionHandler define?






57. What should a REST API generally return for malformed input?






58. Why use a consistent API error response format?






59. What is MethodArgumentNotValidException commonly associated with?






60. Why should stack traces generally not be returned directly to API clients in production?






Data Access with Spring Data JPA

61. What does Spring Data JPA primarily simplify?






62. Which annotation marks a JPA entity class?






63. Which annotation identifies an entity primary key?






64. What is JpaRepository commonly used for?






65. What is a derived query method?






66. What does @Query allow in a repository?






67. What is lazy fetching?






68. What is the N+1 query problem?






69. What does @Transactional provide?






70. Why can Open Session in View be controversial?






Transactions and Persistence

71. What is the main purpose of a database transaction?






72. What does transaction rollback do?






73. What does transaction propagation describe?






74. What does READ_COMMITTED isolation generally prevent?






75. What is a dirty read?






76. What is optimistic locking?






77. Which JPA annotation is commonly used for version-based optimistic locking?






78. What is pessimistic locking?






79. Why should transaction boundaries be chosen carefully?






80. What is a common reason a @Transactional method may not behave as expected when called from the same class?






Spring Security

81. What are authentication and authorization?






82. What is Spring Security primarily used for?






83. What is a SecurityFilterChain used for?






84. What is CSRF protection intended to mitigate?






85. When is CSRF protection especially relevant?






86. What is a PasswordEncoder used for?






87. Why should passwords not be stored as plaintext?






88. What is a JWT commonly used for?






89. What does method security control?






90. Why should authorization checks be enforced server-side?






Actuator and Production Monitoring

91. What is Spring Boot Actuator?






92. Which endpoint commonly exposes application health information?






93. What is /actuator/info commonly used for?






94. Why should Actuator endpoints be secured?






95. What is Micrometer commonly used with Spring Boot for?






96. What is a liveness probe intended to indicate?






97. What is a readiness probe intended to indicate?






98. What is observability commonly composed of?






99. Why are correlation IDs useful?






100. What is a custom Actuator endpoint used for?






Testing Spring Boot Applications

101. Which annotation is commonly used to load a full Spring Boot application context in a test?






102. What is a unit test generally intended to isolate?






103. What is @WebMvcTest commonly used for?






104. What is @DataJpaTest intended to focus on?






105. Why mock external services in many unit tests?






106. What is MockMvc used for?






107. What does an integration test generally verify?






108. Why use test-specific configuration?






109. What is Testcontainers useful for?






110. Why should integration tests avoid relying on shared mutable external state?






Messaging and Event-Driven Spring Boot

111. What is Spring Kafka commonly used for?






112. What is a Kafka topic?






113. What is a Kafka consumer group?






114. What is Spring AMQP commonly used for?






115. What is asynchronous processing useful for?






116. Which annotation can enable Spring asynchronous method execution?






117. Which annotation marks a method for asynchronous execution?






118. Why can message consumers need idempotency?






119. What is a dead-letter queue commonly used for?






120. What is event-driven architecture?






Microservices and Distributed Systems

121. What is Spring Cloud commonly associated with?






122. What is service discovery?






123. What is an API gateway commonly responsible for?






124. What is a circuit breaker intended to do?






125. What is a timeout important for in distributed systems?






126. What is a retry storm?






127. Why use distributed tracing?






128. What is eventual consistency?






129. Why should distributed operations not assume a single local transaction covers every service?






130. What is a saga pattern used for?






Deployment, Containers and Cloud

131. What is a common way to containerize a Spring Boot application?






132. What is the purpose of a Dockerfile?






133. Why use environment variables in container deployments?






134. What is a Kubernetes readiness probe used for?






135. What is a Kubernetes liveness probe used for?






136. Why should container images be kept small?






137. What is a graceful shutdown?






138. Why is externalized configuration important in cloud deployments?






139. What is horizontal scaling?






140. What is a health check used for?






Advanced and Scenario-Based Spring Boot

141. An API is returning database entities directly and exposing internal fields. What is a safer design?






142. A Spring Boot API becomes slow because a controller calls another service synchronously for every request. What should be investigated first?






143. A service occasionally fails when its database is unavailable. Which design helps it fail predictably?






144. Two beans implement the same interface and injection fails with an ambiguity error. What is a direct solution?






145. A REST endpoint performs a long-running report generation. What architecture can improve user experience?






146. A production application needs database credentials that differ by environment. What is appropriate?






147. A cache returns outdated product data after updates. What should be examined?






148. A controller has complex business logic and database calls. What refactoring is usually appropriate?






149. A Spring Boot application has slow startup because many beans are initialized but rarely used. Which feature may help?






150. A microservice repeatedly calls an unavailable dependency and overloads it further. Which pattern addresses this?






Latest Spring Boot 4 and Spring Framework 7

151. Which major Spring Boot version introduced the Spring Framework 7 foundation?






152. What is a major goal of the Spring Boot 4 modularization effort?






153. Which Java version is a first-class target for Spring Framework 7 and Spring Boot 4?






154. What Java baseline does Spring Framework 7 retain for compatibility?






155. Which Jakarta EE generation is supported by Spring Framework 7?






156. What is one important JSON-related change associated with Spring Boot 4?






157. What is a key reason Spring Boot 4 modularized auto-configuration?






158. Which feature was introduced as part of the new Spring Boot 4 generation for REST applications?






159. What is JSpecify used for in modern Spring applications?






160. Which Spring Boot version is currently in the 4.1 stable line as of October 2026?






Jackson 3 and Modern API Development

161. Which JSON library generation is the default direction for Spring Boot 4 applications?






162. What is an important package-level change developers may encounter when migrating from Jackson 2 to Jackson 3?






163. Why should developers pay attention to Jackson 3 default configuration changes during migration?






164. During a gradual Spring Boot 4 migration, what can an application temporarily use?






165. What is API versioning designed to help with?






166. Which approach can be used to distinguish different API versions?






167. What is the main advantage of using DTOs with versioned APIs?






168. What is a common risk when changing an API without versioning or backward compatibility?






169. What does an HTTP Interface Client provide in Spring?






170. Why are declarative HTTP clients useful in microservices?






Modern Spring Boot Testing

171. Which Spring testing feature is designed specifically for testing HTTP endpoints without requiring a running server?






172. What is the main purpose of a test slice such as @WebMvcTest?






173. Why can focused test slices be faster than full @SpringBootTest tests?






174. What is the main benefit of testing a REST API with realistic HTTP requests?






175. What is a key advantage of Testcontainers for Spring Boot integration tests?






176. What problem can Testcontainers help reduce compared with relying only on an in-memory database?






177. What is test context caching intended to improve?






178. What is the purpose of mocking a downstream service in a unit or focused integration test?






179. Which testing strategy is most appropriate for verifying that multiple Spring Boot components work together?






180. Why should integration tests be designed to be repeatable and isolated?






Observability, OpenTelemetry and Production Operations

181. Which three signals are commonly associated with modern application observability?






182. What is OpenTelemetry primarily used for?






183. What does distributed tracing help developers understand?






184. What is a trace span?






185. Why are correlation or trace IDs useful in microservices?






186. What is a Micrometer Observation designed to help capture?






187. What is a readiness check primarily concerned with?






188. Why is liveness different from readiness?






189. Why should high-cardinality metric labels be used carefully?






190. What is a useful production approach when an endpoint becomes unexpectedly slow?






Modern Spring Boot Performance, Security and Cloud-Native Features

191. What is Spring Boot AOT processing intended to do?






192. What is a major benefit of compiling a Spring Boot application to a native executable?






193. Which technology is commonly associated with building Spring applications into native executables?






194. What is a common trade-off of native compilation compared with a traditional JVM deployment?






195. What is an SSL bundle in Spring Boot useful for?






196. Why is SSRF protection important for server-side HTTP clients?






197. Which resilience strategy helps prevent repeated calls to an unavailable downstream service?






198. Why should retry logic include limits or backoff?






199. What is one important consideration when using virtual threads in a Spring Boot application?






200. A Spring Boot 4 application is being upgraded from Spring Boot 3. What is the best general approach?






About the Author
Vaibhav Joshi | Igmguru
About the Author

Vaibhav Joshi has written systems-level and application code in Java, C, and C++ over a career spanning enterprise software and performance-focused projects. Debugging memory issues and bottlenecks under real production load shapes his careful, detail-oriented writing. He tests language and compiler updates directly, helping programmers write efficient, maintainable code.

Drop Us a Query
Fields marked * are mandatory
×

Your Shopping Cart


Your shopping cart is empty.