wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Spring Boot Fundamentals Assessment

Total questions: 20

Worksheet time: 20mins

Name
Class
Date
1.

What is the purpose of Maven in a Spring Boot application?

a)

Maven is a web server for hosting Spring Boot applications.

b)

Maven is a testing framework for Spring Boot applications.

c)

Maven manages dependencies and builds the Spring Boot application.

d)

Maven is used for database management in Spring Boot applications.

2.

How do you create a new Spring Boot project using Maven?

a)

Use Gradle to create the project

b)

Use Spring Initializr or run 'mvn archetype:generate' command.

c)

Run 'npm init' to set up the project

d)

Download a ZIP file of Spring Boot and extract it

3.

What is a Spring Boot Starter?

a)

A Spring Boot Starter is a programming language.

b)

A Spring Boot Starter is a dependency descriptor that simplifies adding libraries and configurations in Spring Boot applications.

c)

A Spring Boot Starter is a type of database.

d)

A Spring Boot Starter is a web server configuration.

4.

Which dependency is required for using Spring Web in a Maven project?

a)

org.springframework:spring-web:5.3.10

b)

org.springframework:spring-core:5.3.10

c)

org.springframework:spring-webmvc:5.3.10

d)

org.springframework:spring-context:5.3.10

5.

What does the @Service annotation indicate in a Spring Boot application?

a)

It indicates that the class is a controller component in the application.

b)

It indicates that the class is a repository component in the application.

c)

It indicates that the class is a service component in the application.

d)

It indicates that the class is a configuration component in the application.

6.

How do you define a REST controller in Spring Boot?

a)

Use @Controller annotation to define a REST controller in Spring Boot.

b)

Use @Service annotation to create a REST controller in Spring Boot.

c)

Define a REST controller by implementing the Controller interface.

d)

Use @RestController annotation to define a REST controller in Spring Boot.

7.

What is the purpose of the @Component annotation?

a)

To create a new Spring application context.

b)

To manage application security settings.

c)

To indicate that a class is a Spring-managed component.

d)

To define a database entity.

8.

How can you create a bean in Spring Boot using the @Bean annotation?

a)

Use the @Component annotation instead of @Bean.

b)

Create a bean by directly instantiating it in the main application class.

c)

Annotate a field with @Bean in any class.

d)

Define a method in a @Configuration class, instantiate the object, and annotate the method with @Bean.

9.

What is the role of the @Repository annotation in Spring Boot?

a)

The @Repository annotation is used for configuring web security.

b)

The @Repository annotation is for defining REST controllers.

c)

The @Repository annotation is used to manage application properties.

d)

The @Repository annotation marks a class as a DAO and enables exception translation in Spring Boot.

10.

How do you configure embedded Tomcat in a Spring Boot application?

a)

Manually install Tomcat in the project directory

b)

Spring Boot automatically configures embedded Tomcat; customize via application.properties or a TomcatServletWebServerFactory bean.

c)

Use a web.xml file for configuration

d)

Configure Tomcat using a standalone server

11.

What is the default port for the embedded Tomcat server in Spring Boot?

a)

8080

b)

9090

c)

8000

d)

8081

12.

How do you enable Actuator endpoints in a Spring Boot application?

a)

Add 'spring-boot-starter-web' dependency and set 'management.endpoints.web.exposure.enabled=true' in application.properties.

b)

Add 'spring-boot-starter-actuator' dependency and set 'management.endpoints.web.exposure.include=*' in application.properties.

c)

Use 'spring-boot-starter-actuator' and set 'management.endpoints.web.exposure.exclude=*' in application.properties.

d)

Include 'spring-boot-actuator' in the build.gradle file and set 'management.endpoints.web.exposure.include=health' in application.yml.

13.

What is the purpose of the /actuator/health endpoint?

a)

To provide the health status of the application.

b)

To log application errors.

c)

To display application configuration settings.

d)

To provide user authentication details.

14.

How can you customize the Actuator endpoints in your application?

a)

Customize Actuator endpoints via application.properties or application.yml.

b)

Modify Actuator endpoints directly in the source code.

c)

Use a web interface to change Actuator settings.

d)

Customize Actuator endpoints via command line arguments.

15.

What is the significance of the @Controller annotation?

a)

The @Controller annotation is used to create service classes in Spring.

b)

The @Controller annotation signifies that a class is a Spring MVC controller responsible for handling web requests.

c)

The @Controller annotation is used to define a database entity.

d)

The @Controller annotation is for configuring security settings in Spring.

16.

How do you return a JSON response from a REST controller?

a)

Use @ResponseBody to return a plain text response.

b)

Return a JSON response by manually converting the object to a string.

c)

Use @GetMapping or @PostMapping to return an object, which is automatically converted to JSON.

d)

Use @RequestMapping with a void return type.

17.

What is the difference between @Service and @Component?

a)

@Service is used for repository components; @Component is for utility classes.

b)

@Service is for data access components; @Component is for configuration.

c)

@Service is for service layer components; @Component is a general-purpose stereotype.

d)

@Service is a deprecated annotation; @Component is the preferred choice.

18.

How can you access the Actuator metrics endpoint?

a)

Use a DELETE request to '/actuator/metrics'

b)

Access the metrics through the '/metrics' endpoint

c)

Send a POST request to '/actuator/metrics'

d)

Send an HTTP GET request to '/actuator/metrics'.

19.

What is the use of application.properties in a Spring Boot project?

a)

To store user data in a Spring Boot project.

b)

The application.properties file is used for configuration settings in a Spring Boot project.

c)

To manage database connections in a Spring Boot project.

d)

To define the main class of the Spring Boot application.

20.

How do you run a Spring Boot application packaged as a JAR file?

a)

Double-click the JAR file to run it

b)

Use the command 'java -jar your-application.jar' in the terminal.

c)

Execute 'java start your-application.jar' in the command prompt

d)

Run the application using 'run your-application.jar'