Learn. Practice. Feel prepared.
Spring Boot Objective Questions and Answers - Set 3
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. This is part 3 of the series.
Practice Spring Boot MCQs with Detailed Explanations
Answer at least 12 questions to submit and verify answers.
31 What is the main benefit of Spring Boot starters? Medium
Correct answer:
Reduce boilerplate dependencies
Starters aggregate commonly used dependencies for faster setup.
32 Which annotation disables a specific auto-configuration? Hard
Correct answer:
@SpringBootApplication(exclude = ...)
Auto-configurations can be excluded using the exclude attribute.
33 What is the default port of a Spring Boot application? Easy
Correct answer:
8080
Spring Boot runs on port 8080 by default.
34 Which annotation is used to inject environment-specific beans? Medium
Correct answer:
@Profile
@Profile activates beans only for specific environments.
35 What is the default logging framework in Spring Boot? Medium
Correct answer:
Logback
Spring Boot uses Logback as the default logging implementation.
36 Which annotation maps path variables in REST APIs? Easy
Correct answer:
@PathVariable
@PathVariable binds URI template variables to method parameters.
37 Which annotation marks a bean for lazy initialization? Medium
Correct answer:
@Lazy
@Lazy delays bean initialization until it is needed.
38 What happens when an exception is not handled in a REST controller? Medium
Correct answer:
Default error response is returned
Spring Boot returns a default error response with appropriate status code.
39 Which annotation enables scheduling? Medium
Correct answer:
@EnableScheduling
@EnableScheduling activates scheduled task execution.
40 Which annotation is used to schedule a task? Medium
Correct answer:
@Scheduled
@Scheduled defines scheduled task execution using cron or fixed delays.
41 Which property file takes higher precedence? Hard
Correct answer:
command-line arguments
Command-line arguments have the highest priority in Spring Boot.
42 What does @MockBean do in tests? Hard
Correct answer:
Mocks a bean in application context
@MockBean replaces a real bean with a mock during tests.
43 Which annotation is used to return HTTP status explicitly? Medium
Correct answer:
@ResponseStatus
@ResponseStatus sets HTTP status code for responses or exceptions.
44 What is the main purpose of Spring Boot DevTools? Medium
Correct answer:
Developer productivity
DevTools improves developer experience with auto-restart and live reload.
45 Which annotation enables caching? Medium
Correct answer:
@EnableCaching
@EnableCaching activates Spring’s annotation-driven cache management.