Spring Boot Quiz - MCQ - Multiple Choice Questions

This post contains a few useful Spring Boot (MCQ) multiple-choice questions (quiz) to self-test your knowledge of the Spring Boot framework.

The answers to each question have been given at end of this post.

Q1. Spring Boot is used for developing?

  1. Web applications
  2. Distributed applications (Restful web services)
  3. Microservices
  4. All of the above

Q2. What is Spring Initializer?

  1. A web-based tool for generating a basic Spring Boot project structure
  2. A command-line tool for generating a basic Spring Boot project structure
  3. A tool for initializing a Spring-based application with a specific set of dependencies
  4. A tool for creating a Spring Boot application with a specific set of features

Q3. What does Spring Boot do to simplify the configuration of a Spring-based application?

  1. Automatically configures necessary beans and dependencies
  2. Uses annotations to configure beans and dependencies
  3. Allows for the use of XML configuration files
  4. Provides a command line interface for configuring the application

Q4. How can a Spring Boot application be packaged and distributed? 

  1. As a JAR file 
  2. As a WAR file 
  3. As a ZIP file 
  4. All of the above

Q5. Which Spring annotation is used to create RESTful web services using Spring MVC?

  1. @RestController
  2. @Controller
  3. @Component
  4. @Rest

Q6. @RestController annotation is a combination of the below two annotations

  1. @Component and @ResponseBody annotations
  2. @Controller and @ResponseBody annotations
  3. @Service and @ResponseBody annotations
  4. None of the above

Q7. Which Spring annotation is used to handle HTTP POST requests?

  1. @GetMapping
  2. @PutMapping
  3. @CreateMapping
  4. @PostMapping

Q8. Which Spring annotation is used to handle HTTP GET requests?

  1. @GetMapping
  2. @PutMapping
  3. @CreateMapping
  4. @PostMapping

Q9. Which Spring annotation is used to handle HTTP DELETE requests?

  1. @GetMapping
  2. @PutMapping
  3. @DeleteMapping
  4. @PostMapping

Q10. Which Spring annotation is used to handle HTTP PUT requests?

  1. @GetMapping
  2. @PutMapping
  3. @DeleteMapping
  4. @PostMapping

Q11. Which annotation do we use to mark the class as a Service class/component?

  1. @Component
  2. @Service
  3. @Controller
  4. @Repository

Q12. Which is the default implementation class of the JpaRepository interface?

  1. SimpleJpaRepository class
  2. JpaRepositoryImpl class
  3. CustomJpaRepository class
  4. DefaultJpaRepository class

Q13. Which is the default HTML template in Spring Boot

  1. JSP
  2. Freemarker
  3. Thymeleaf
  4. Groovy

Q14. Which starter dependency is used to develop web applications or Restful web services?

  1. spring-boot-starter-data-jpa
  2. spring-boot-starter-web
  3. spring-boot-starter-rest
  4. spring-boot-starter-web-dependency

Q15. What is the purpose of the Spring Boot Actuator? 

  1. To provide production-ready features such as monitoring and metrics 
  2. To provide a way to configure beans using annotations 
  3. To provide a way to run Spring Boot applications as a service 
  4. To provide a way to access the underlying database of a Spring Boot application

Q16. How can you specify the port on which a Spring Boot application runs? 

  1. By modifying the application.properties file 
  2. By modifying the application.yml file 
  3. By using the --server.port command-line option 
  4. All of the above

Q17. What is the purpose of the Spring Boot DevTools? 

  1. To provide a way to run Spring Boot applications in a development environment 
  2. To provide hot-reloading of code changes 
  3. To provide a way to run Spring Boot applications as a service 
  4. To provide a way to access the underlying database of a Spring Boot application

Q18. What is the difference between Spring and Spring Boot? 

  1. Spring is a Java framework, while Spring Boot is a Java library 
  2. Spring Boot is an opinionated version of Spring, providing a set of default configurations 
  3. Spring Boot is a lightweight version of Spring, while Spring is a full-featured framework 
  4. Spring Boot is a front-end framework, while Spring is a back-end framework 

Q19. How does Spring Boot handle logging? 

  1. By using Log4j 
  2. By using Logback 
  3. By using SLF4J 
  4. By using JUL (Java Util Logging)

Q20. What is the @SpringBootApplication annotation used for? 

  1. To enable Spring Boot auto-configuration 
  2. To define a Spring Boot starter class 
  3. To define a Spring Boot controller 
  4. To define a Spring Boot service

Q21. Which annotation Spring Boot provides for Integration testing?

  1. @SpringBootTest annotation
  2. @WebMvcTest annotation
  3. @DataJpaTest annotation
  4. None of the above

Q22. Which annotation is used to unit test Spring MVC Controllers?

  1. @SpringBootTest annotation
  2. @WebMvcTest annotation
  3. @DataJpaTest annotation
  4. None of the above

Q23. Which annotation we have used to unit test the Spring Data JPA repository?

  1. @SpringBootTest annotation
  2. @WebMvcTest annotation
  3. @DataJpaTest annotation
  4. None of the above

Q24. What are the Spring annotations used for Exception handling?

  1. @ControllerAdvice
  2. @ExceptionHandler
  3. Both

Q25.  Minimum Java version used for Spring Boot 3?

  1. Java 8
  2. Java 11
  3. Java 17
  4. Java 10

Q26. What is the difference between PUT and PATCH in REST API? 

  1. PUT completely replaces the resource, while PATCH modifies only the fields specified in the request body 
  2. PUT is used to update the resource, while PATCH is used to create a resource 
  3. PUT is used to retrieve data, while PATCH is used to update data 
  4. PUT is used to delete the resource, while PATCH is used to update the resource

Answers

Q1

All of the above

Q2

A web-based tool for generating a basic Spring Boot project structure

Q3

Automatically configures necessary beans and dependencies

Q4

All of the above
Q5

@RestController
Q6

@Controller and @ResponseBody annotations
Q7

@PostMapping
Q8

@GetMapping
Q9

@DeleteMapping
Q10

@PutMapping
Q11

@Service

Q12

SimpleJpaRepository class
Q13

Thymeleaf
Q14

spring-boot-starter-web
Q15

To provide production-ready features such as monitoring and metrics 
Q16

All of the above
Q17

To provide hot-reloading of code changes 
Q18

Spring Boot is an opinionated version of Spring, providing a set of default configurations 
Q19

By using Logback 
Q20

To enable Spring Boot auto-configuration 
Q21

@SpringBootTest annotation
Q22

@WebMvcTest annotation
Q23

@DataJpaTest annotation
Q24

Both
Q25

Java 17
Q26

PUT completely replaces the resource, while PATCH modifies only the fields specified in the request body

Free Spring Boot Tutorial | Full In-depth Course | Learn Spring Boot in 10 Hours


Watch this course on YouTube at Spring Boot Tutorial | Fee 10 Hours Full Course