Welcome to the Spring Boot Data Access MCQ (Multiple Choice Questions) guide. Here, we present a set of MCQ questions to test your knowledge of Spring Boot Data Access.
Note that each question is followed by the correct answer and an explanation to help reinforce your knowledge.
1. Which starter dependency is typically added for JPA-based applications in Spring Boot?
Answer:
Explanation:
The spring-boot-starter-data-jpa dependency provides all the necessary functionalities to develop JPA-based applications with Spring Boot.
2. In Spring Boot, which interface primarily facilitates CRUD operations?
Answer:
Explanation:
CrudRepository provides a generic CRUD operation on a repository for a specific type.
3. Which annotation is used to indicate a JPA entity in Spring Boot?
Answer:
Explanation:
The @Entity annotation is used to indicate that a class is a JPA entity.
4. How do you define a custom query method in a Spring Data repository?
Answer:
Explanation:
The @Query annotation allows for defining custom queries directly in the repository interface.
5. Which annotation is used to auto-wire a repository in a Spring Boot service or controller?
Answer:
Explanation:
The @Autowired annotation is used for automatic dependency injection.
6. To perform paging and sorting in Spring Data, which interface should the repository extend?
Answer:
Explanation:
The PagingAndSortingRepository provides methods to perform paging and sorting of records.
7. Which annotation is used to denote a transactional boundary in Spring Boot?
Answer:
Explanation:
The @Transactional annotation is used to define the scope of a single database transaction.
8. Which property helps define the DDL (Data Definition Language) auto-generation strategy in Spring Boot?
Answer:
Explanation:
The property spring.jpa.hibernate.ddl-auto determines the auto-generation strategy for DDL.
9. How can you define a named native query in a JPA Entity?
Answer:
Explanation:
The @NameNativeQuery annotation is used to specify a named native SQL query.
10. Which of the following is the default database connection pool in Spring Boot 2.x?
Answer:
Explanation:
Starting from Spring Boot 2.x, HikariCP is the default connection pool.
11. Which interface primarily facilitates custom query method implementations?
Answer:
Explanation:
The JpaSpecificationExecutor interface allows for the creation of custom query methods using the criteria API.
12. To configure the number of connections in the HikariCP pool, which property is used?
Answer:
Explanation:
The spring.datasource.hikari.maximumPoolSize property determines the maximum number of connections in the HikariCP pool.
Related Spring Boot MCQ Posts
- Spring Boot Starters MCQ - Multiple Choice Questions and Answers
- Spring Boot Auto Configurations MCQ - Multiple Choice Questions and Answers
- Spring Boot Properties & Configuration MCQ - Multiple Choice Questions and Answers
- Spring Boot Data Access MCQ - Multiple Choice Questions and Answers
- Spring Boot Actuator MCQ - Multiple Choice Questions and Answers
- Spring Boot Security MCQ - Multiple Choice Questions and Answers
- Spring Boot Testing MCQ - Multiple Choice Questions and Answers
- Spring Boot Microservices MCQ - Multiple Choice Questions and Answers
Comments
Post a Comment
Leave Comment