Springboot MCQs with answers Page - 15

Here, you will find a collection of MCQ questions on Springboot. Go through these questions to enhance your preparation for upcoming examinations and interviews.

To check the correct answer, simply click the View Answer button provided for each question.

Have your own questions to contribute? Click the button below to share your MCQs with others!

+ Add Question

S

Shyam Dubey • 3.70K Points
Extraordinary

Q. What does @EnableCaching do in a Spring Boot application?

  • (A) Disables cache
  • (B) Marks method results for storage
  • (C) Enables Spring’s annotation-driven cache management
  • (D) Caches entire controller class

S

Shyam Dubey • 3.70K Points
Extraordinary

Q. Which annotation is used for mapping HTTP PUT requests?

  • (A) @PutRequest
  • (B) @PutMapping
  • (C) @Put
  • (D) @RequestPut

S

Shyam Dubey • 3.70K Points
Extraordinary

Q. What does @CrossOrigin annotation handle?

  • (A) Handles routing
  • (B) Handles dependency injection
  • (C) Allows cross-origin requests (CORS)
  • (D) Enables HTTPS redirection

S

Shyam Dubey • 3.70K Points
Extraordinary

Q. Which property enables lazy initialization of beans?

  • (A) spring.lazy=true
  • (B) spring.bean.init.lazy=true
  • (C) spring.main.lazy-initialization=true
  • (D) lazy.init=true

S

Shyam Dubey • 3.70K Points
Extraordinary

Q. Which method retrieves the application environment in Spring Boot?

  • (A) context.getEnv()
  • (B) System.getenv()
  • (C) SpringApplication.getEnvironment()
  • (D) ApplicationContext.getEnvironment()

S

Shyam Dubey • 3.70K Points
Extraordinary

Q. What is the use of CommandLineRunner in Spring Boot?

  • (A) To run code after security setup
  • (B) To test data layer
  • (C) To run code after the application context is loaded
  • (D) To configure logging

S

Shyam Dubey • 3.70K Points
Extraordinary

Q. Which of the following annotations is used for path variable binding?

  • (A) @Path
  • (B) @Param
  • (C) @PathVariable
  • (D) @RouteParam

S

Shyam Dubey • 3.70K Points
Extraordinary

Q. Which annotation is used to automatically wire dependencies?

  • (A) @Inject
  • (B) @Autowired
  • (C) @Resource
  • (D) @Dependency

S

Shyam Dubey • 3.70K Points
Extraordinary

Q. How do you define an in-memory H2 database in Spring Boot?

  • (A) Include H2 dependency and no additional config
  • (B) Use spring.db.type=H2
  • (C) Define it in server.xml
  • (D) Use @EnableH2Database

S

Shyam Dubey • 3.70K Points
Extraordinary

Q. What does the @SpringBootTest annotation do?

  • (A) Starts the embedded database only
  • (B) Starts a full Spring application context for integration testing
  • (C) Used only to test controllers
  • (D) Runs tests without Spring context