What annotation is used in Spring Boot to expose a method as a REST API endpoint?
REST API and MySQL Quiz SKG

Quiz
•
Computers
•
12th Grade
•
Medium
PEARLS 5
Used 2+ times
FREE Resource
15 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
20 sec • 1 pt
@Service
@RestController
@Repository
@RequestMapping
Answer explanation
The @RestController annotation in Spring Boot is used to define a controller that handles RESTful web services. It combines @Controller and @ResponseBody, making it ideal for exposing methods as REST API endpoints.
2.
MULTIPLE CHOICE QUESTION
20 sec • 1 pt
Which annotation is used to bind path variables in a URL to method parameters in Spring Boot?
@PathVariable
@RequestParam
@RequestBody
@Entity
Answer explanation
The @PathVariable annotation in Spring Boot is used to extract values from the URI path and bind them to method parameters, making it the correct choice for this question.
3.
MULTIPLE CHOICE QUESTION
20 sec • 1 pt
To fetch a list of employees based on their department, which SQL query would you use?
SELECT * FROM employees WHERE department = 'HR';
UPDATE employees SET department = 'HR';
DELETE FROM employees WHERE department = 'HR';
INSERT INTO employees (department) VALUES ('HR');
Answer explanation
The correct choice is 'SELECT * FROM employees WHERE department = 'HR';' because it retrieves all employees in the HR department. The other options modify or delete data instead of fetching it.
4.
MULTIPLE CHOICE QUESTION
20 sec • 1 pt
What annotation is used to define a primary key in a JPA entity?
@Entity
@Id
@GeneratedValue
@Table
Answer explanation
The @Id annotation is used in JPA to specify the primary key of an entity. It uniquely identifies each instance of the entity, making it essential for database operations.
5.
MULTIPLE CHOICE QUESTION
20 sec • 1 pt
A client sends a POST request to /products with product details. How would you represent the inserted product in the database using SQL?
INSERT INTO products (name, price) VALUES ('Phone', 1000);
SELECT * FROM products;
DELETE FROM products WHERE name = 'Phone';
UPDATE products SET price = 1000 WHERE name = 'Phone';
Answer explanation
The correct choice is 'INSERT INTO products (name, price) VALUES ('Phone', 1000);' as it accurately represents adding a new product with the specified details into the database.
6.
MULTIPLE CHOICE QUESTION
20 sec • 1 pt
What is the purpose of the @RequestBody annotation in Spring Boot?
To map HTTP request body to a Java object
To bind query parameters to method arguments
To define a database entity
To log HTTP requests
Answer explanation
The @RequestBody annotation in Spring Boot is used to map the HTTP request body to a Java object, allowing for easy data transfer between the client and server. This makes it essential for handling JSON or XML payloads.
7.
MULTIPLE CHOICE QUESTION
20 sec • 1 pt
Which command is used to create a database in MySQL?
CREATE TABLE database_name;
CREATE DATABASE database_name;
USE database_name;
INSERT INTO database_name;
Answer explanation
The correct command to create a database in MySQL is 'CREATE DATABASE database_name;'. The other options are either for creating tables, selecting databases, or inserting data, not for creating a database.
Create a free account and access millions of resources
Similar Resources on Quizizz
12 questions
Database Knowledge Check 3 (SQL)

Quiz
•
9th - 12th Grade
15 questions
Introduction to MySQL

Quiz
•
11th - 12th Grade
18 questions
SQL Quiz

Quiz
•
12th Grade
15 questions
BASIS DATA XII (PSAS II2023)

Quiz
•
12th Grade
15 questions
Databases

Quiz
•
10th Grade - University
15 questions
A-Level Comp Sci 9618 Databases

Quiz
•
9th - 12th Grade
15 questions
Learning SQL

Quiz
•
11th - 12th Grade
10 questions
MySQL Python Connectivity

Quiz
•
12th Grade - University
Popular Resources on Quizizz
15 questions
Character Analysis

Quiz
•
4th Grade
17 questions
Chapter 12 - Doing the Right Thing

Quiz
•
9th - 12th Grade
10 questions
American Flag

Quiz
•
1st - 2nd Grade
20 questions
Reading Comprehension

Quiz
•
5th Grade
30 questions
Linear Inequalities

Quiz
•
9th - 12th Grade
20 questions
Types of Credit

Quiz
•
9th - 12th Grade
18 questions
Full S.T.E.A.M. Ahead Summer Academy Pre-Test 24-25

Quiz
•
5th Grade
14 questions
Misplaced and Dangling Modifiers

Quiz
•
6th - 8th Grade
Discover more resources for Computers
17 questions
Chapter 12 - Doing the Right Thing

Quiz
•
9th - 12th Grade
30 questions
Linear Inequalities

Quiz
•
9th - 12th Grade
20 questions
Types of Credit

Quiz
•
9th - 12th Grade
20 questions
Taxes

Quiz
•
9th - 12th Grade
17 questions
Parts of Speech

Quiz
•
7th - 12th Grade
20 questions
Chapter 3 - Making a Good Impression

Quiz
•
9th - 12th Grade
20 questions
Inequalities Graphing

Quiz
•
9th - 12th Grade
10 questions
Identifying equations

Quiz
•
KG - University