Welcome to Set 5 of our 100+ Spring Boot MCQ Questions and Answers series. This Set 5 continues from MCQs 41-50 and covers Spring Boot fundamentals 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
41. What is the primary use of the @Repository annotation in Spring Boot?
Answer:
Explanation:
The @Repository annotation in Spring Boot is used to mark a class as a repository, which indicates that it's responsible for data access and interactions with the database.
42. In Spring Boot, what is the purpose of the spring-boot-starter-jdbc dependency?
Answer:
Explanation:
The spring-boot-starter-jdbc starter includes dependencies for using JDBC with Spring Boot, simplifying database access and operations using JDBC.
43. What is the purpose of the spring-boot-starter-aop dependency?
Answer:
Explanation:
The spring-boot-starter-aop starter includes dependencies for Aspect-Oriented Programming (AOP), enabling developers to implement cross-cutting concerns such as logging and transaction management.
44. What is the primary role of the spring-boot-starter-cache dependency?
Answer:
Explanation:
The spring-boot-starter-cache starter provides support for caching abstraction in Spring Boot applications. It simplifies the integration of caching solutions like EhCache, Hazelcast, or Caffeine.
45. How can you handle exceptions globally in a Spring Boot application?
Answer:
Explanation:
The @ControllerAdvice annotation in Spring Boot handles exceptions globally across multiple controllers, allowing for centralized exception handling in a Spring Boot application.
46. What is the main purpose of the @EnableJpaRepositories annotation in Spring Boot?
Answer:
Explanation:
The @EnableJpaRepositories annotation in Spring Boot is used to enable JPA repository support, allowing Spring to scan for JPA repository interfaces and create proxy implementations.
47. What is the role of the @Valid annotation in Spring Boot?
Answer:
Explanation:
The @Valid annotation in Spring Boot is used in controller methods to ensure that data passed to the method is valid, often used in combination with Java Bean Validation API.
48. How is internationalization (i18n) typically implemented in Spring Boot?
Answer:
Explanation:
Internationalization in Spring Boot is typically implemented using properties files for different locales (e.g., messages_en.properties, messages_fr.properties). This allows for easy translation and localization of application messages.
49. What is the primary purpose of the @ModelAttribute annotation in a Spring Boot web application?
Answer:
Explanation:
The @ModelAttribute annotation in Spring Boot is used in controller methods to bind method parameters to named model attributes, often used in form submission handling.
50. In Spring Boot, which starter dependency is typically used for developing web applications with Thymeleaf templates?
Answer:
Explanation:
The spring-boot-starter-thymeleaf starter is used to develop web applications with Thymeleaf templates. It provides integration with the Thymeleaf templating engine for building dynamic web pages.
❮ Previous Set Next Set ❯
Comments
Post a Comment
Leave Comment