Spring Boot MCQ

Spring Boot, a sub-project of the Spring framework, has gained tremendous popularity among Java developers. Its primary strength lies in simplifying the creation and deployment of Spring applications by removing much of the boilerplate configuration. If you're new to Spring Boot, this set of Multiple Choice Questions (MCQs) offers a gentle introduction and a way to test your foundational knowledge.

1. What is the primary purpose of Spring Boot?

a) Mobile application development
b) Microservice creation
c) Simplified Spring application setup
d) Frontend UI development

2. Which embedded server does Spring Boot provide by default for web applications?

a) Jetty
b) JBoss
c) Apache Tomcat
d) GlassFish

3. What role do "starters" play in Spring Boot?

a) They serve as entry points for applications.
b) They provide a set of default dependencies for specific tasks.
c) They define application properties.
d) They handle database migrations.

4. Which file format cannot be used to configure properties in Spring Boot?

a) .XML
b) .properties
c) .json
d) .yml

5. Which annotation activates Spring Boot's auto-configuration?

a) @Activate
b) @SpringBootApplication
c) @AutoConfigure
d) @Configure

6. How does Spring Boot decide whether to autoconfigure a specific feature?

a) Based on classes available in the classpath
b) Depending on the JVM version
c) Based on the spring.xml configuration file
d) By analyzing the database schema

7. What does Actuator in Spring Boot provide?

a) API documentation
b) Security features
c) Production-ready features like health checks and metrics
d) Data binding

8. To externalize Spring Boot's configuration, where can properties be specified?

a) application.properties
b) springboot.properties
c) config.properties
d) external.properties

9. What is the purpose of spring-boot-starter-parent?

a) It provides useful Maven defaults.
b) It contains core libraries for Spring Boot.
c) It adds logging dependencies.
d) It generates a basic project structure.

10. How can you specify a specific port number for your Spring Boot application?

a) By modifying the server.xml file
b) By adding server.port= in the application.properties file
c) By using the @Port annotation
d) By configuring the embedded server manually

11. What is the primary advantage of using Spring Boot?

a) Enhanced Performance
b) Modular Development
c) Rapid Development
d) Rich User Interface

12. How does Spring Boot simplify database configurations?

a) By eliminating the need for a database
b) By using conventions for data source URLs and drivers
c) By using JPA as the only option
d) By automating table creation

13. If you want to override Spring Boot's default configurations, which file should you modify?

a) spring.xml
b) boot-config.properties
c) application.yml or application.properties
d) boot.properties

14. Which of these is a benefit of using Spring Boot?

a) Eliminates the need for code
b) Reduces boilerplate code
c) Guarantees bug-free applications
d) Only supports web applications

15. What is the primary purpose of @SpringBootApplication annotation?

a) Only to activate component scanning
b) Just to enable Spring Boot's autoconfiguration
c) To launch the embedded Tomcat server
d) A combination of component scanning, autoconfiguration, and Spring Boot's configuration

16. Which annotation is specifically used to indicate that a class provides Bean definitions?

a) @Bean
b) @Entity
c) @Configuration
d) @Component

17. What is the primary function of @Conditional annotation in Spring Boot?

a) To run SQL conditional statements
b) To specify that a component should only be configured under specific circumstances
c) To execute conditions during runtime
d) To validate bean properties

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

a) @RestController
b) @Controller
c) @Component
d) @Rest

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

a) @GetMapping
b) @PutMapping
c) @CreateMapping
d) @PostMapping

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

a) spring-boot-starter-data-jpa
b) spring-boot-starter-web
c) spring-boot-starter-rest
d) spring-boot-starter-web-dependency


Comments