Spring Boot MCQ Questions and Answers | Set 10

Welcome to Set 10 of our 100+ Spring Boot MCQ Questions and Answers series. This Set 10 continues from MCQs 91-100 and covers Spring Boot and Spring framework modules.

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

91. What is the role of the @Table annotation in a JPA entity?

a) To define a RESTful endpoint
b) To specify the table in the database to which the entity is mapped
c) To configure application properties
d) To create scheduled tasks

Answer:

b) To specify the table in the database to which the entity is mapped

Explanation:

The @Table annotation in a JPA entity is used to specify the table in the database to which the entity should be mapped. It can include the table name, catalog, schema, and unique constraints.

92. Which Spring Boot starter is used for integrating Apache Cassandra?

a) spring-boot-starter-cassandra
b) spring-boot-starter-data-cassandra
c) spring-boot-starter-jdbc
d) spring-boot-starter-data-redis

Answer:

b) spring-boot-starter-data-cassandra

Explanation:

The spring-boot-starter-data-cassandra starter is used for integrating Apache Cassandra, a NoSQL database, into Spring Boot applications. It includes support for Cassandra operations and configurations.

93. What is the primary use of the @ManyToOne annotation in JPA?

a) To define a many-to-one relationship between two entities
b) To configure application properties
c) To create scheduled tasks
d) To define RESTful endpoints

Answer:

a) To define a many-to-one relationship between two entities

Explanation:

The @ManyToOne annotation in JPA is used to define a many-to-one relationship between two entities. It specifies that many entities are mapped to one target entity.

94. How can you define custom query methods in a Spring Data repository?

a) By using the @QueryMethod annotation
b) Through XML configuration
c) By declaring methods in the repository interface
d) By manually implementing the repository methods

Answer:

c) By declaring methods in the repository interface

Explanation:

Custom query methods in a Spring Data repository can be defined by declaring methods in the repository interface. Spring Data derives the query from the method name or uses the provided @Query annotation.

95. What is the use of @OneToOne annotation in JPA?

a) To define a one-to-one relationship between two entities
b) To configure application properties
c) To create scheduled tasks
d) To define RESTful endpoints

Answer:

a) To define a one-to-one relationship between two entities

Explanation:

The @OneToOne annotation in JPA is used to define a one-to-one relationship between two entities. It indicates that one entity is associated with another entity having a one-to-one relationship.

96. What is the primary use of the @OneToMany annotation in JPA?

a) To define a one-to-many relationship between two entities
b) To configure application properties
c) To create scheduled tasks
d) To define RESTful endpoints

Answer:

a) To define a one-to-many relationship between two entities

Explanation:

The @OneToMany annotation in JPA is used to define a one-to-many relationship between two entities. It specifies that one entity is associated with multiple instances of another entity.

97. What is the role of the @Version annotation in a JPA entity?

a) To define a RESTful endpoint
b) To enable optimistic locking by marking a field as a version column
c) To configure application properties
d) To create scheduled tasks

Answer:

b) To enable optimistic locking by marking a field as a version column

Explanation:

The @Version annotation in a JPA entity is used to enable optimistic locking by marking a field as a version column. This field is used to ensure data integrity during concurrent updates.

98. How does Spring Boot simplify the integration with Apache Kafka?

a) By providing the spring-boot-starter-kafka dependency
b) Through manual configuration of Kafka clients
c) By embedding a Kafka server within the application
d) Through XML-based configuration

Answer:

a) By providing the spring-boot-starter-kafka dependency

Explanation:

Spring Boot simplifies the integration with Apache Kafka by providing the spring-boot-starter-kafka dependency. It includes support for Kafka template and consumer/producer configurations.

99. What is the purpose of the @Lob annotation in a JPA entity?

a) To define a large object (LOB) field in the database
b) To configure application properties
c) To create scheduled tasks
d) To define RESTful endpoints

Answer:

a) To define a large object (LOB) field in the database

Explanation:

The @Lob annotation in a JPA entity is used to define a Large Object (LOB) field in the database, such as a BLOB (Binary Large Object) or CLOB (Character Large Object).

100. How does Spring Boot support reactive data access?

a) By using the R2DBC API
b) Through the JdbcTemplate class
c) By manual reactive programming
d) Through XML-based configuration

Answer:

a) By using the R2DBC API

Explanation:

Spring Boot supports reactive data access by using the R2DBC (Reactive Relational Database Connectivity) API. It provides non-blocking and reactive programming support for relational databases.


Comments