Spring Data MCQ - Multiple Choice Questions and Answers


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?

a) Web service endpoints
b) Data validation tools
c) Data-access patterns implementation
d) Deployment mechanisms

2. The @Query annotation in Spring Data is used to:

a) Configure the data source
b) Define custom queries
c) Automate transaction management
d) Specify the primary key field

3. To expose repository methods as REST endpoints, you would use:

a) Spring Data REST
b) Spring Data JPA
c) Spring Data JDBC
d) Spring Data Web

4. Which of the following Spring Data projects supports Reactive Programming?

a) Spring Data JPA
b) Spring Data JDBC
c) Spring Data R2DBC
d) Spring Data Commons

5. In Spring Data, which annotation is used to indicate a field as the primary key?

a) @PrimaryKey
b) @Id
c) @Key
d) @EntityId

6. Which Spring Data module provides support for Apache Cassandra?

a) Spring Data Cassandra
b) Spring Data NoSQL
c) Spring Data Commons
d) Spring Data KeyValue

7. For defining derived delete queries in Spring Data, which keyword can be used within method names?

a) RemoveBy
b) DeleteFrom
c) EraseBy
d) DeleteBy

8. The @EnableJpaRepositories annotation is used to:

a) Enable Spring Security for JPA repositories
b) Activate Spring Data JPA repositories
c) Enable JPA's second-level cache
d) Initialize JPA EntityManager

9. What does the @Transactional annotation do in Spring Data?

a) Makes a method run within a database transaction
b) Ensures data integrity
c) Provides isolation between concurrent transactions
d) All of the above

10. In Spring Data, what is a Projection?

a) A database view
b) A 3D representation of data
c) A subset of attributes of an entity
d) A replication of the database

11. The @Modifying annotation in Spring Data is typically used with:

a) SELECT queries
b) DELETE or UPDATE queries
c) Stored procedures
d) @Entity beans

12. For which of the following databases does Spring Data NOT offer dedicated support?

a) MongoDB
b) Redis
c) Neo4j
d) SQLite

13. The @LastModifiedDate annotation in Spring Data is useful for tracking...

a) Entity creation dates
b) Entity modification dates
c) Entity access dates
d) Entity deletion dates

14. Which annotation is used to mark a method to execute a native SQL query in Spring Data JPA?

a) @SQLQuery
b) @ExecuteSQL
c) @NativeQuery
d) @Query(nativeQuery = true)

15. Which annotation is used to denote a named query in Spring Data JPA?

a) @NamedQuery
b) @NameQuery
c) @SelectQuery
d) @FindQuery

Related Spring MCQ Posts


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