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?
Answer:
Explanation:
Static resources like CSS, JavaScript, and images in a Spring Boot web application can be served by placing them in the /static or /public directory of the application. Spring Boot automatically configures these as static resource locations.
32. What is the primary use of the @Query annotation in Spring Data JPA?
Answer:
Explanation:
The @Query annotation in Spring Data JPA is used to define a JPA query for a repository method. It allows custom query definitions directly on repository interface methods.
33. In Spring Boot, what is the purpose of the @EnableAutoConfiguration annotation?
Answer:
Explanation:
The @EnableAutoConfiguration annotation in Spring Boot is used to enable auto-configuration of the Spring application context, attempting to guess and configure beans that are likely needed based on the classpath contents.
34. How can you secure a RESTful endpoint in Spring Boot?
Answer:
Explanation:
RESTful endpoints in Spring Boot can be secured using Spring Security, which provides comprehensive security services, including authentication and authorization.
35. What is the purpose of the @JsonBackReference and @JsonManagedReference annotations in Spring Boot?
Answer:
Explanation:
@JsonBackReference and @JsonManagedReference annotations are used in Spring Boot to handle recursive relationships during JSON serialization and deserialization, preventing issues like infinite recursion.
36. What is the role of the @CrossOrigin annotation in a Spring Boot application?
Answer:
Explanation:
The @CrossOrigin annotation in Spring Boot enables cross-origin requests on specific handler classes or handler methods, allowing resources to be accessed from a domain other than the domain where the resource originated.
37. In Spring Boot, how can you externalize configuration?
Answer:
Explanation:
Configuration in Spring Boot can be externalized using environment variables and properties files (application.properties or application.yml), allowing for different configurations in different environments.
38. What is the purpose of the @PathVariable annotation in Spring Boot?
Answer:
Explanation:
The @PathVariable annotation in Spring Boot is used in controller methods to bind a method parameter to a named variable in a URI template.
39. Which component is responsible for handling view resolution in a Spring Boot web application?
Answer:
Explanation:
In a Spring Boot web application, the ViewResolver component resolves views by name and determines which view technology to use for rendering the UI.
40. How can you enable transaction management in a Spring Boot application?
Answer:
Explanation:
The @Transactional annotation enables transaction management in Spring Boot. It can be applied to classes or methods that require transactional behavior.
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
Comments
Post a Comment
Leave Comment