Spring Boot MCQ Questions and Answers | Set 4


Welcome to Set 4 of our 100+ Spring Boot MCQ Questions and Answers series. This Set 4 continues from MCQs 31-40 and covers Spring Boot basics and annotations.

Complete Spring Boot MCQ Questions and Answers series:

Spring Boot MCQ Questions and Answers | Set 1

Spring Boot MCQ Questions and Answers | Set 2

Spring Boot MCQ Questions and Answers | Set 3

Spring Boot MCQ Questions and Answers | Set 4

Spring Boot MCQ Questions and Answers | Set 5

Spring Boot MCQ Questions and Answers | Set 6

Spring Boot MCQ Questions and Answers | Set 7

Spring Boot MCQ Questions and Answers | Set 8

Spring Boot MCQ Questions and Answers | Set 9

Spring Boot MCQ Questions and Answers | Set 10

31. How are static resources served in a Spring Boot web application?

a) Through a dedicated controller
b) By placing them in the /static or /public directory
c) Using a specialized static server
d) By manual configuration in the application.properties file

32. What is the primary use of the @Query annotation in Spring Data JPA?

a) To create native SQL queries
b) To define a JPA query for a repository method
c) To configure database connections
d) To create HTML templates

33. In Spring Boot, what is the purpose of the @EnableAutoConfiguration annotation?

a) To enable batch processing
b) To automatically configure Spring framework based on classpath settings
c) To configure application properties
d) To enable WebSocket functionality

34. How can you secure a RESTful endpoint in Spring Boot?

a) Using the @Secure annotation
b) By defining security configurations in application.properties
c) Through Spring Security and its configuration
d) By using a separate security server

35. What is the purpose of the @JsonBackReference and @JsonManagedReference annotations in Spring Boot?

a) To configure RESTful web services
b) To handle recursive relationships in JSON serialization and deserialization
c) To define the primary and foreign keys in a database
d) To configure application properties

36. What is the role of the @CrossOrigin annotation in a Spring Boot application?

a) To enable batch processing
b) To configure application security
c) To define a scheduled task
d) To allow cross-origin requests in a web application

37. In Spring Boot, how can you externalize configuration?

a) By using environment variables
b) Through application.properties or application.yml files
c) By creating XML configuration files
d) Both a) and b)

38. What is the purpose of the @PathVariable annotation in Spring Boot?

a) To bind a method parameter to a path variable in a URL
b) To define a request parameter
c) To configure request headers
d) To return a response body

39. Which component is responsible for handling view resolution in a Spring Boot web application?

a) JdbcTemplate
b) ViewResolver
c) DataSource
d) WebMvcConfigurer

40. How can you enable transaction management in a Spring Boot application?

a) By using the @Transactional annotation
b) Through XML configuration
c) By manually managing transactions in the service layer
d) By using a specialized transaction management server

Comments

Spring Boot 3 Paid Course Published for Free
on my Java Guides YouTube Channel

Subscribe to my YouTube Channel (165K+ subscribers):
Java Guides Channel

Top 10 My Udemy Courses with Huge Discount:
Udemy Courses - Ramesh Fadatare