wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

SpringBoot Day1,day2

Total questions: 25

Worksheet time: 25mins

Name
Class
Date
1.

Lokesh wants to configure application level properties

in a Spring-starter-project, In which

Lokesh can configure them?

a)

server-config.xml

b)

application.properties

c)

settings.json

d)

config.ini

2.

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?

a)

application.properties

b)

pom.xml

c)

mvnw.cmd

d)

dom.xml

3.

Which JPA method is used to insert a new entity into the database?

a)

find()

b)

persist()

c)

merge()

d)

remove()

e)

insert()

4.

What does the find() method in JPA do?

a)

Finds an entity by its ID and returns a managed entity

b)

Finds all entities in the database

c)

Finds an entity and immediately deletes it

d)

Checks if an entity is null

5.

Which JPA method is used to update an entity that is detached from the persistence context?

a)

find()

b)

persist()

c)

update()

d)

remove()

e)

merge()

6.

What does the remove() method do in JPA?

a)

Removes an entity from the database

b)

Removes an entity from the persistence context but not the database

c)

Marks an entity as inactive

d)

Moves the entity to an archive table


7.

Surekha created a Spring Boot project using Spring Initializr. Which dependency is required to use Spring Data JPA?

a)

spring-boot-starter-web

b)

spring-boot-starter-data-jpa

c)

spring-boot-starter-thymeleaf

d)

spring-boot-starter-security


8.

Kusuma is adding MySQL database support to her Spring Boot project. Which file should she modify to configure the database connection?

b)

config.xml

c)

database.yml

d)

server.json

9.

Abitej wants to define a JPA entity for a Student table. Which annotation should he use on his class?

a)

@Repository

b)

@Entity

c)

@Service

d)

@Autowired

10.

Radhika Mam created a StudentRepository interface. Which interface should it extend to perform CRUD operations automatically? ( Assuming Student Id is Long)

a)

JpaRepository<Student, Long>

b)

CrudOperations<Student, Long>

c)

DatabaseManager<Student, Long>

d)

HibernateCrud<Student, Long>

11.

Harrishwar wants to fetch a record using its primary key (id). Which method from JpaRepository should he use?

a)

findAll()

b)

findById(id)

c)

deleteById(id)

d)

persist(id)

e)

findId(id)

12.

Shruthika wants to insert a new student record into the database using Spring Data JPA. Which method should she use?

a)

save(entity)

b)

create(entity)

c)

insert(entity)

d)

add(entity)

13.

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?

a)

delete(id)

b)

removeById(id)

c)

deleteById(id)

d)

erase(id)

14.

Kusuma wants to retrieve all student records from the database. Which method from JPA Repository should she use?

a)

fetchAll()

b)

findAll()

c)

getAll()

d)

retrieveAll()

15.

Likitha tried to delete an entity using delete(entity), but the entity was not managed. What could be the issue?

a)

(A)The entity is not in the persistence context

b)

(B)The entity does not exist in the database

c)

(C)delete(entity) only works for new records

d)

Both (A) & (B)

16.

Ajay is learning about Thymeleaf in Spring Boot. What is Thymeleaf mainly used for?

a)

Managing databases

b)

Creating REST APIs

c)

Rendering dynamic HTML pages

d)

Writing backend logic

17.

Pujitha wants to display a user's name dynamically in an HTML file. Which Thymeleaf syntax should she use?

18.

Srija created a Spring Boot controller that adds an attribute "student" to the model. How can she access it in Thymeleaf?

a)

${student}

b)

@{student}

c)

#{student}

d)

!{student}

19.

Fajia has a list of students stored in a List<Student> students. How can she iterate over this list in Thymeleaf?

a)

<ul th:each="student : ${students}">

b)

<ul th:forEach="student in students">

c)

<ul iterate="students">

d)

<ul loop="${students}">

20.

Nandana wants to create a hyperlink in Thymeleaf that navigates to the /home page. Which syntax should she use?

a)

<a href="/home">Home</a>

b)

<a th:href="@{/home}">Home</a>

c)

<a th:href="${/home}">Home</a>

d)

<a th:link="/home">Home</a>

e)

<a th:goto="@{/home}">Home</a>

21.

Raju is creating a form to submit user details. Which attribute should he use in Thymeleaf to bind form data to a model?

a)

th:value

b)

th:field

c)

th:bind

d)

th:model

e)

th:text

22.

Observe the given endpoint :

/students/data?page=1&size=5&sortBy=id&direction=asc/students/data?page=1\&size=5\&sortBy=id\&direction=asc

Yasaswi wants to retrieve the value sizesize , Which annotation is helpful to him?

a)

@QueryParam

b)

@RequestParam

c)

@PathVariable

d)

@ModelAttribute

e)

@GetParam

23.

Observe the given endpoint

/students/edit/{id}/students/edit/\left\{id\right\}

Sweta wants to capture idid in a method of Controller Class,

which Annotation is helpful to her

a)

@QueryParam

b)

@RequestParam

c)

@ModelAttribute

d)

@PathVariable

e)

@GetId

24.

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)  

25.

Which HTTP method used to retrieve the resource from the server?

a)

GET

b)

POST

c)

PUT

d)

DELETE

e)

PATCH