Welcome to the Spring Data MCQ (Multiple Choice Questions) guide, Here, we present a set of MCQ questions to test your knowledge of Spring Data and its sub-modules.
Note that each question is followed by the correct answer and an explanation to help reinforce your knowledge.
1. What does Spring Data primarily aim to provide?
Answer:
Explanation:
Spring Data's primary goal is to provide an implementation for data access patterns, reducing boilerplate code and simplifying data access.
2. The @Query annotation in Spring Data is used to:
Answer:
Explanation:
The @Query annotation is used to specify custom queries directly within repository interfaces.
3. To expose repository methods as REST endpoints, you would use:
Answer:
Explanation:
Spring Data REST allows you to expose CRUD operations on repository entities directly as REST endpoints.
4. Which of the following Spring Data projects supports Reactive Programming?
Answer:
Explanation:
Spring Data R2DBC provides reactive programming support for relational databases.
5. In Spring Data, which annotation is used to indicate a field as the primary key?
Answer:
Explanation:
The @Id annotation is used to denote a field in the domain class as the primary key.
6. Which Spring Data module provides support for Apache Cassandra?
Answer:
Explanation:
Spring Data Cassandra provides easy configuration and access to Apache Cassandra.
7. For defining derived delete queries in Spring Data, which keyword can be used within method names?
Answer:
Explanation:
You can define derived delete queries using the DeleteBy keyword in method names.
8. The @EnableJpaRepositories annotation is used to:
Answer:
Explanation:
@EnableJpaRepositories is used to activate Spring Data JPA repositories in the application.
9. What does the @Transactional annotation do in Spring Data?
Answer:
Explanation:
The @Transactional annotation ensures that a method runs within a transactional context, providing features like data integrity and isolation.
10. In Spring Data, what is a Projection?
Answer:
Explanation:
Projections in Spring Data provide a way to retrieve a subset of attributes of an entity or DTOs (Data Transfer Objects).
11. The @Modifying annotation in Spring Data is typically used with:
Answer:
Explanation:
The @Modifying annotation is used to highlight that a query changes the data in the database, typically with DELETE or UPDATE operations.
12. For which of the following databases does Spring Data NOT offer dedicated support?
Answer:
Explanation:
While Spring Data offers specialized modules for MongoDB, Redis, and Neo4j, there isn't a dedicated module for SQLite.
13. The @LastModifiedDate annotation in Spring Data is useful for tracking...
Answer:
Explanation:
The @LastModifiedDate annotation helps in tracking the last modified date of an entity.
14. Which annotation is used to mark a method to execute a native SQL query in Spring Data JPA?
Answer:
Explanation:
The @Query annotation with nativeQuery = true is used to execute native SQL queries.
15. Which annotation is used to denote a named query in Spring Data JPA?
Answer:
Explanation:
The @NamedQuery annotation is used to define named queries in JPA.
Related Spring MCQ Posts
- Spring IOC Container MCQ - Multiple Choice Questions and Answers
- Spring Dependency Injection MCQ - Multiple Choice Questions and Answers
- Spring Beans MCQ - Multiple Choice Questions and Answers
- Spring Configuration MCQ - Multiple Choice Questions and Answers
- Spring AOP MCQ - Multiple Choice Questions and Answers
- Spring JDBC MCQ - Multiple Choice Questions and Answers
- Spring Data MCQ - Multiple Choice Questions and Answers
- Spring Messaging MCQ - Multiple Choice Questions and Answers
- Spring Batch MCQ - Multiple Choice Questions and Answers
- Spring WebFlux MCQ - Multiple Choice Questions and Answers
- Spring Testing Quiz - MCQ - Multiple Choice Questions
- Spring Security Quiz - MCQ - Multiple Choice Questions
Comments
Post a Comment
Leave Comment