Font size
WorksheetsSpringBoot Day1,day2
Total questions: 25
Worksheet time: 25mins
Lokesh wants to configure application level properties
in a Spring-starter-project, In which
Lokesh can configure them?
server-config.xml
application.properties
settings.json
config.ini
Nivetha wants to define dependencies ( 'spring-boot-starter-jpa','spring-boot-starter-thymeleaf') in her
Maven Based Spring boot project. In which file she need to define those dependencies?
application.properties
pom.xml
mvnw.cmd
dom.xml
Which JPA method is used to insert a new entity into the database?
find()
persist()
merge()
remove()
insert()
What does the find() method in JPA do?
Finds an entity by its ID and returns a managed entity
Finds all entities in the database
Finds an entity and immediately deletes it
Checks if an entity is null
Which JPA method is used to update an entity that is detached from the persistence context?
find()
persist()
update()
remove()
merge()
What does the remove() method do in JPA?
Removes an entity from the database
Removes an entity from the persistence context but not the database
Marks an entity as inactive
Moves the entity to an archive table
Surekha created a Spring Boot project using Spring Initializr. Which dependency is required to use Spring Data JPA?
spring-boot-starter-web
spring-boot-starter-data-jpa
spring-boot-starter-thymeleaf
spring-boot-starter-security
Kusuma is adding MySQL database support to her Spring Boot project. Which file should she modify to configure the database connection?
Abitej wants to define a JPA entity for a Student table. Which annotation should he use on his class?
@Repository
@Entity
@Service
@Autowired
Radhika Mam created a StudentRepository interface. Which interface should it extend to perform CRUD operations automatically? ( Assuming Student Id is Long)
JpaRepository<Student, Long>
CrudOperations<Student, Long>
DatabaseManager<Student, Long>
HibernateCrud<Student, Long>
Harrishwar wants to fetch a record using its primary key (id). Which method from JpaRepository should he use?
findAll()
findById(id)
deleteById(id)
persist(id)
findId(id)
Shruthika wants to insert a new student record into the database using Spring Data JPA. Which method should she use?
save(entity)
create(entity)
insert(entity)
add(entity)
Surekha used a function from JPA Repository(Spring Data JPA) to delete
a record but mistakenly used findById(id).
What should she use to correctly delete the record?
delete(id)
removeById(id)
deleteById(id)
erase(id)
Kusuma wants to retrieve all student records from the database. Which method from JPA Repository should she use?
fetchAll()
findAll()
getAll()
retrieveAll()
Likitha tried to delete an entity using delete(entity), but the entity was not managed. What could be the issue?
(A)The entity is not in the persistence context
(B)The entity does not exist in the database
(C)delete(entity) only works for new records
Both (A) & (B)
Ajay is learning about Thymeleaf in Spring Boot. What is Thymeleaf mainly used for?
Managing databases
Creating REST APIs
Rendering dynamic HTML pages
Writing backend logic
Srija created a Spring Boot controller that adds an attribute "student" to the model. How can she access it in Thymeleaf?
${student}
@{student}
#{student}
!{student}
Fajia has a list of students stored in a List<Student> students. How can she iterate over this list in Thymeleaf?
<ul th:each="student : ${students}">
<ul th:forEach="student in students">
<ul iterate="students">
<ul loop="${students}">
Nandana wants to create a hyperlink in Thymeleaf that navigates to the /home page. Which syntax should she use?
<a href="/home">Home</a>
<a th:href="@{/home}">Home</a>
<a th:href="${/home}">Home</a>
<a th:link="/home">Home</a>
<a th:goto="@{/home}">Home</a>
Raju is creating a form to submit user details. Which attribute should he use in Thymeleaf to bind form data to a model?
th:value
th:field
th:bind
th:model
th:text
Observe the given endpoint :
/students/data?page=1&size=5&sortBy=id&direction=asc
Yasaswi wants to retrieve the value size , Which annotation is helpful to him?
@QueryParam
@RequestParam
@PathVariable
@ModelAttribute
@GetParam
Observe the given endpoint
/students/edit/{id}
Sweta wants to capture id in a method of Controller Class,
which Annotation is helpful to her
@QueryParam
@RequestParam
@ModelAttribute
@PathVariable
@GetId
In Spring Boot, Which Annotation is used to define a class as a spring Bean,
making it eligible for Spring's auto detection and wiring capabilities?
(Write exact annotation as per java syntax with symbol @ )
(a)
Which HTTP method used to retrieve the resource from the server?
GET
POST
PUT
DELETE
PATCH
