Learn. Practice. Feel prepared.
Spring Boot Objective Questions and Answers
Test your Spring Boot skills with carefully curated MCQs designed for real-world development and interview preparation. Focused on configuration, REST APIs, data access, security, and production-ready applications.
Practice Spring Boot MCQs with Detailed Explanations
Answer at least 12 questions to submit and verify answers.
1 What is the primary purpose of Spring Boot auto-configuration? Medium
Correct answer:
To automatically configure beans based on classpath dependencies
Spring Boot auto-configuration attempts to automatically configure application components based on available dependencies and defaults.
2 Which annotation is responsible for enabling component scanning in Spring Boot? Medium
Correct answer:
@SpringBootApplication
@SpringBootApplication is a meta-annotation that includes component scanning, auto-configuration, and configuration support.
3 What happens if two beans of the same type exist and no qualifier is specified? Medium
Correct answer:
Application fails at startup
Spring throws a NoUniqueBeanDefinitionException when it cannot resolve which bean to inject.
4 Which embedded server is used by default in Spring Boot? Easy
Correct answer:
Tomcat
Spring Boot uses Apache Tomcat as the default embedded servlet container.
5 Which annotation is used to bind external configuration properties to a POJO? Medium
Correct answer:
@ConfigurationProperties
@ConfigurationProperties binds a group of properties to a strongly typed bean.
6 What is the default scope of a Spring bean? Easy
Correct answer:
singleton
By default, Spring beans are singleton scoped.
7 Which HTTP status code is returned by default for a successful POST request? Medium
Correct answer:
201
A successful POST request typically returns HTTP 201 Created.
8 Which annotation is used to handle exceptions globally in REST controllers? Medium
Correct answer:
@ControllerAdvice
@ControllerAdvice allows centralized exception handling across controllers.
9 What is the role of application.properties or application.yml? Medium
Correct answer:
Externalize application configuration
These files are used to externalize and manage application configuration.
10 Which annotation is mandatory for a Spring Boot main class? Easy
Correct answer:
@SpringBootApplication
@SpringBootApplication is the recommended annotation to bootstrap a Spring Boot app.
11 What does @RestController combine? Medium
Correct answer:
@Controller and @ResponseBody
@RestController is a convenience annotation that combines @Controller and @ResponseBody.
12 Which JPA method retrieves data lazily by default? Hard
Correct answer:
getOne()
getOne() returns a proxy and fetches data lazily when accessed.
13 What is the default transaction propagation behavior? Hard
Correct answer:
REQUIRED
REQUIRED joins an existing transaction or creates a new one if none exists.
14 Which annotation enables Spring Security in a Boot application? Medium
Correct answer:
@EnableWebSecurity
@EnableWebSecurity activates Spring Security configuration.
15 What will happen if spring.datasource.url is missing? Medium
Correct answer:
Application fails at startup
Without datasource configuration, the application fails unless an embedded DB is available.