Spring Boot MCQ Test

20 random Spring Boot MCQs with answers: auto-configuration, REST controllers, Spring Data JPA, validation, profiles, security with JWT, testing and Actuator.

  • 20 random questions
  • 20 minutes
  • 30 in the question bank

No sign-up needed. Answers and explanations are shown at the end.

About this test

Spring Boot is the most requested Java skill in job posts. This test covers building REST APIs, Spring Data repositories, validation and error handling, configuration and profiles, security, testing and deployment.

Every question comes from the Spring Boot lessons, so you can open the matching lesson for anything you miss.

Each attempt picks new questions at random from the question bank. You can go back and change answers until you finish or the timer runs out. At the end you see your score, the right answer and a short explanation for every question, and the lessons to revise for the ones you missed.

Sample questions with answers

1. @SpringBootApplication combines…

  1. @RestController and @Bean
  2. @SpringBootConfiguration, @EnableAutoConfiguration and @ComponentScan
  3. @Service and @Repository
Show answer

B. @SpringBootConfiguration, @EnableAutoConfiguration and @ComponentScan — Keep it in the root package so scanning finds everything.

2. Which status should a successful create return?

  1. 204 No Content
  2. 200 OK
  3. 201 Created with a Location header
Show answer

C. 201 Created with a Location header — Location points to the new resource.

3. What does findByTitleContainingIgnoreCase do?

  1. Nothing until implemented
  2. Spring derives a case-insensitive LIKE query from the name
  3. Loads all rows
Show answer

B. Spring derives a case-insensitive LIKE query from the name — Derived queries are checked at startup.

4. Why return DTOs instead of entities?

  1. Stable contract, no over-exposure, no lazy-loading or JSON loops
  2. DTOs are faster to write
  3. Entities can't be serialised
Show answer

A. Stable contract, no over-exposure, no lazy-loading or JSON loops — Records make great DTOs.

5. Which logging style is correct?

  1. log.info("Enrolled {}", id)
  2. log.info("Enrolled " + id) everywhere
  3. System.out.println in production
Show answer

A. log.info("Enrolled {}", id) — Placeholders avoid building strings when disabled.

6. 401 vs 403?

  1. 401: not authenticated; 403: authenticated but not allowed
  2. 403 means not found
  3. They're the same
Show answer

A. 401: not authenticated; 403: authenticated but not allowed — A student deleting a course gets 403.

7. Which test starts only the web layer with MockMvc?

  1. @DataJpaTest
  2. @SpringBootTest
  3. @WebMvcTest
Show answer

C. @WebMvcTest — Services are replaced with mocks.

8. Why use @EntityGraph on a detail query?

  1. To load the course and its lessons in one query
  2. To cache results
  3. To sort lessons
Show answer

A. To load the course and its lessons in one query — It prevents N+1 and lazy errors.

9. What does /actuator/health report?

  1. The source code
  2. All environment variables
  3. Whether the app (and checks like the database) is UP
Show answer

C. Whether the app (and checks like the database) is UP — Load balancers use it.

10. Where is "max 3 active courses" enforced?

  1. In the service layer, returning 409 via a business exception
  2. In the browser
  3. In the controller
Show answer

A. In the service layer, returning 409 via a business exception — Rules belong in services and entities.