Web services with Spring Boot Flashcards

1
Q

What is a web service in the context of Java development?

a) A method with a graphical user interface (GUI)
b) A method exposed to and run on the web without a GUI
c) A standalone desktop application
d) A database management system

A

b) A method exposed to and run on the web without a GUI

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is Spring Boot primarily used for?

a) Building desktop applications
b) Quickly building and deploying standalone Java web applications
c) Managing databases
d) Creating graphical user interfaces

A

b) Quickly building and deploying standalone Java web applications

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is the purpose of the Spring Initializr?

a) To manage database connections
b) To quickly build and configure starting project files for Spring Boot
c) To create graphical user interfaces
d) To debug Java applications

A

b) To quickly build and configure starting project files for Spring Boot

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Which of the following is NOT a dependency added in the Spring Initializr for the weather application?

a) Spring Web
b) Vaadin
c) Spring Data for Apache Cassandra
d) Spring Security

A

d) Spring Security

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is the purpose of the pom.xml file in a Maven project?

a) To define the graphical user interface
b) To manage project dependencies and configurations
c) To store database credentials
d) To define RESTful endpoints

A

b) To manage project dependencies and configurations

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What does the MVC design pattern stand for?

a) Model, View, Controller
b) Main, View, Controller
c) Model, View, Configuration
d) Main, View, Configuration

A

a) Model

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is the role of the Controller in the MVC pattern?

a) To handle the structure of the data
b) To manage the user interface
c) To abstract the model from the view and handle data requests
d) To store data in the database

A

c) To abstract the model from the view and handle data requests

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What annotation is used to define a class as a RESTful controller in Spring Boot?

a) @Controller
b) @RestController
c) @RequestMapping
d) @GetMapping

A

b) @RestController

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What annotation is used to specify the base service name for a RESTful controller in Spring Boot?

a) @Controller
b) @RestController
c) @RequestMapping
d) @GetMapping

A

c) @RequestMapping

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What HTTP method is used to retrieve data in a RESTful service?

a) POST
b) PUT
c) GET
d) DELETE

A

c) GET

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is the purpose of the @GetMapping annotation in Spring Boot?

a) To define a POST endpoint
b) To define a GET endpoint
c) To define a PUT endpoint
d) To define a DELETE endpoint

A

b) To define a GET endpoint

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

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

a) 8080
b) 80
c) 443
d) 3000

A

a) 8080

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is the purpose of the ResponseEntity class in Spring Boot?

a) To define the structure of the data
b) To manage the user interface
c) To represent the entire HTTP response, including status code and body
d) To store data in the database

A

c) To represent the entire HTTP response

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What HTTP response code is returned by the ResponseEntity.ok() method?

a) 200
b) 404
c) 500
d) 403

A

a) 200

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is the purpose of the curl command in the context of testing RESTful services?

a) To create a new web service
b) To make HTTP requests from the command line
c) To manage database connections
d) To debug Java applications

A

b) To make HTTP requests from the command line

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is the correct curl command to test the helloworld endpoint of the weather application?

a) curl -X POST http://127.0.0.1:8080/weather/helloworld
b) curl -X GET http://127.0.0.1:8080/weather/helloworld
c) curl -X PUT http://127.0.0.1:8080/weather/helloworld
d) curl -X DELETE http://127.0.0.1:8080/weather/helloworld

A

b) curl -X GET http://127.0.0.1:8080/weather/helloworld

17
Q

What is the purpose of the @RestController annotation in Spring Boot?

a) To define a class as a RESTful controller
b) To define a GET endpoint
c) To define a POST endpoint
d) To define a PUT endpoint

A

a) To define a class as a RESTful controller

18
Q

What is the purpose of the @RequestMapping annotation in Spring Boot?

a) To define a class as a RESTful controller
b) To specify the base service name for a RESTful controller
c) To define a GET endpoint
d) To define a POST endpoint

A

b) To specify the base service name for a RESTful controller

19
Q

What is the purpose of the @GetMapping annotation in Spring Boot?

a) To define a class as a RESTful controller
b) To specify the base service name for a RESTful controller
c) To define a GET endpoint
d) To define a POST endpoint

A

c) To define a GET endpoint

20
Q

What is the purpose of the ResponseEntity.ok() method in Spring Boot?

a) To return an HTTP response with a 200 status code
b) To return an HTTP response with a 404 status code
c) To return an HTTP response with a 500 status code
d) To return an HTTP response with a 403 status code

A

a) To return an HTTP response with a 200 status code