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?
- Web applications
- Distributed applications (Restful web services)
- Microservices
- All of the above
Q2. What is Spring Initializer?
- A web-based tool for generating a basic Spring Boot project structure
- A command-line tool for generating a basic Spring Boot project structure
- A tool for initializing a Spring-based application with a specific set of dependencies
- 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?
- Automatically configures necessary beans and dependencies
- Uses annotations to configure beans and dependencies
- Allows for the use of XML configuration files
- Provides a command line interface for configuring the application
Q4. How can a Spring Boot application be packaged and distributed?
- As a JAR file
- As a WAR file
- As a ZIP file
- All of the above
Q5. Which Spring annotation is used to create RESTful web services using Spring MVC?
- @RestController
- @Controller
- @Component
- @Rest
Q6. @RestController annotation is a combination of the below two annotations
- @Component and @ResponseBody annotations
- @Controller and @ResponseBody annotations
- @Service and @ResponseBody annotations
- None of the above
Q7. Which Spring annotation is used to handle HTTP POST requests?
- @GetMapping
- @PutMapping
- @CreateMapping
- @PostMapping
Q8. Which Spring annotation is used to handle HTTP GET requests?
- @GetMapping
- @PutMapping
- @CreateMapping
- @PostMapping
Q9. Which Spring annotation is used to handle HTTP DELETE requests?
- @GetMapping
- @PutMapping
- @DeleteMapping
- @PostMapping
Q10. Which Spring annotation is used to handle HTTP PUT requests?
- @GetMapping
- @PutMapping
- @DeleteMapping
- @PostMapping
Q11. Which annotation do we use to mark the class as a Service class/component?
- @Component
- @Service
- @Controller
- @Repository
Q12. Which is the default implementation class of the JpaRepository interface?
- SimpleJpaRepository class
- JpaRepositoryImpl class
- CustomJpaRepository class
- DefaultJpaRepository class
Q13. Which is the default HTML template in Spring Boot
- JSP
- Freemarker
- Thymeleaf
- Groovy
Q14. Which starter dependency is used to develop web applications or Restful web services?
- spring-boot-starter-data-jpa
- spring-boot-starter-web
- spring-boot-starter-rest
- spring-boot-starter-web-dependency
Q15. What is the purpose of the Spring Boot Actuator?
- To provide production-ready features such as monitoring and metrics
- To provide a way to configure beans using annotations
- To provide a way to run Spring Boot applications as a service
- 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?
- By modifying the application.properties file
- By modifying the application.yml file
- By using the --server.port command-line option
- All of the above
Q17. What is the purpose of the Spring Boot DevTools?
- To provide a way to run Spring Boot applications in a development environment
- To provide hot-reloading of code changes
- To provide a way to run Spring Boot applications as a service
- To provide a way to access the underlying database of a Spring Boot application
Q18. What is the difference between Spring and Spring Boot?
- Spring is a Java framework, while Spring Boot is a Java library
- Spring Boot is an opinionated version of Spring, providing a set of default configurations
- Spring Boot is a lightweight version of Spring, while Spring is a full-featured framework
- Spring Boot is a front-end framework, while Spring is a back-end framework
Q19. How does Spring Boot handle logging?
- By using Log4j
- By using Logback
- By using SLF4J
- By using JUL (Java Util Logging)
Q20. What is the @SpringBootApplication annotation used for?
- To enable Spring Boot auto-configuration
- To define a Spring Boot starter class
- To define a Spring Boot controller
- To define a Spring Boot service
Q21. Which annotation Spring Boot provides for Integration testing?
- @SpringBootTest annotation
- @WebMvcTest annotation
- @DataJpaTest annotation
- None of the above
Q22. Which annotation is used to unit test Spring MVC Controllers?
- @SpringBootTest annotation
- @WebMvcTest annotation
- @DataJpaTest annotation
- None of the above
Q23. Which annotation we have used to unit test the Spring Data JPA repository?
- @SpringBootTest annotation
- @WebMvcTest annotation
- @DataJpaTest annotation
- None of the above
Q24. What are the Spring annotations used for Exception handling?
- @ControllerAdvice
- @ExceptionHandler
- Both
Q25. Minimum Java version used for Spring Boot 3?
- Java 8
- Java 11
- Java 17
- Java 10
Q26. What is the difference between PUT and PATCH in REST API?
- PUT completely replaces the resource, while PATCH modifies only the fields specified in the request body
- PUT is used to update the resource, while PATCH is used to create a resource
- PUT is used to retrieve data, while PATCH is used to update data
- 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
Related Posts
- Java String Quiz
- Java Arrays Quiz
- Java Loops Quiz
- Java OOPS Quiz
- Java OOPS Quiz - Part 1
- Java OOPS Quiz - Part 2
- Java Exception Handling Quiz
- Java Collections Quiz
- Java Generics Quiz
- Java Multithreading Quiz
- JDBC Quiz
- Java Lambda Expressions Quiz
- Java Functional Interfaces Quiz
- Java Streams API Quiz
- Java Date Time Quiz
- Java 8 Quiz
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