Unit 6: SQL Server and ASP.NET Core Web API - Practice Quiz
1 What is SQL Server primarily used for?
2 Which SQL command is used to retrieve data from a table?
INSERT
UPDATE
DELETE
SELECT
3 Which SQL command adds a new row to a table?
CREATE
INSERT
DROP
ALTER
4 What does a row in a SQL Server table usually represent?
5 What does a column in a table represent?
6 Which constraint uniquely identifies each row in a table?
7
Which constraint prevents a column from containing NULL values?
8 What is the purpose of a SQL join?
9 Which join returns matching rows from both tables?
10 What does REST commonly describe?
11 In REST, resources are commonly identified using what?
12 Which HTTP method is commonly used to retrieve data?
POST
DELETE
PUT
GET
13 Which HTTP method is commonly used to create a new resource?
POST
HEAD
PATCH
GET
14
What does HTTP status code 200 OK indicate?
15
What does HTTP status code 404 Not Found mean?
16 What is ASP.NET Core Web API used to build?
17 What is the main role of an API controller?
18 What does routing determine in a Web API?
19 What is the main purpose of a DTO?
20
What does the letter D represent in CRUD?
21 A developer needs a relational database system that supports transactions, security, stored procedures, and integration with .NET applications. Which SQL Server component is primarily responsible for storing and processing relational data?
22 Which SQL statement correctly increases the salary by 10% for employees in department 3?
23
A table named Orders must store an automatically generated integer identifier for every order. Which column definition is most appropriate?
OrderId DATE DEFAULT GETDATE()
OrderId INT IDENTITY(1,1)
OrderId VARCHAR(20)
OrderId DECIMAL(2,1)
24
A StudentCourses table should prevent the same student from being enrolled in the same course more than once. Which constraint is most suitable?
NOT NULL constraint on the enrollment status
UNIQUE constraint on StudentId and CourseId
CHECK constraint on the enrollment date
DEFAULT constraint on CourseId
25
The Orders.CustomerId column references Customers.CustomerId. What is the main purpose of this foreign key constraint?
26
A report must list every department, including departments that currently have no employees. Which join should be used between Departments and Employees?
27 Which query returns customers who have placed at least one order, without requiring customers with no orders to appear?
28 Which design best follows REST principles for retrieving a product with identifier 42?
POST /getProduct?id=42
POST /api/products with a body containing only the identifier and an instruction to retrieve the product
GET /api/products/42
GET /api/getProductAction/42
29 A REST API is described as stateless. What does this mean for requests?
30
A client sends PUT /api/products/7 with a complete replacement representation of product 7. Which behavior is normally associated with PUT?
31 Which HTTP method is most appropriate for partially updating only the email address of an existing user?
32 An API successfully creates a new customer and returns the URI of the created resource in the response headers. Which status code is most appropriate?
33 A client sends valid JSON to an endpoint, but the requested product identifier does not exist. Which response status is most appropriate?
34 Which ASP.NET Core service is commonly registered to allow controllers to handle HTTP API requests?
AddRazorPagesOnly()
UseStaticFiles()
AddControllers()
AddSqlServer()
35
In a typical ASP.NET Core Web API application, why is app.MapControllers() required when attribute-routed controllers are used?
36
What is the main benefit of deriving an ASP.NET Core API controller from ControllerBase instead of Controller?
37
Given the route template [Route("api/[controller]")] and an action marked [HttpGet("{id:int}")] in ProductsController, which URL matches the action?
POST /api/Products/12
GET /api/Products/12
GET /api/Product?id=12
GET /Products/api/12
38
A User entity contains PasswordHash, but the API should return only Id, Name, and Email. What is the best approach?
PasswordHash to make it less recognizable
39
An API receives a POST request with a valid ProductCreateDto, saves the product, and must return the created resource. Which response is most suitable?
Unauthorized with the product identifier
NoContent without any response headers
CreatedAtAction with the created product
BadRequest because POST cannot return a resource
40 What is a practical benefit of adding Swagger/OpenAPI to an ASP.NET Core Web API?
41 A transaction updates rows in a SQL Server database and then fails before committing. Which behavior best describes the effect of a correctly handled rollback?
42
A developer executes DELETE FROM Orders without a WHERE clause inside an explicit transaction. Which statement is most accurate?
43
A table stores CustomerId, ProductId, Quantity, and UnitPrice for each order line. Which design best prevents duplicate product entries for the same order while preserving separate lines for different products?
CustomerId and ProductId
Quantity and UnitPrice
CustomerId alone
UnitPrice to the product table
44
A nullable column has a UNIQUE constraint in SQL Server. Which behavior should an application generally account for?
45 A query must return every department, including departments with no employees, and employee information when available. Which join is required when departments are placed on the left side?
46
A query joins Orders to OrderItems and then calculates total order value. The result is grouped only by order ID. What issue is most likely if the join condition is incomplete?
47 An endpoint creates a resource only when the client supplies a chosen identifier, and repeating the same request produces the same final resource state. Which REST property is primarily demonstrated?
48 A REST API returns a representation containing links to retrieve related resources and perform valid next actions. Which constraint does this most directly support?
49
A client sends PUT /api/products/42 with a complete representation, but product 42 does not exist. Which response is most appropriate when the API creates the resource at that URI?
201 Created with the resource location
204 No Content with validation errors
409 Conflict because PUT cannot create resources
200 OK with no response body
50
A client sends a conditional GET with If-None-Match, and the server's current ETag matches the supplied value. What should the server normally return?
200 OK with the complete representation
304 Not Modified without the representation body
201 Created with a replacement representation
412 Precondition Failed for every matching tag
51 A request is syntactically valid and authenticated, but the authenticated user is not allowed to access the requested resource. Which status code best communicates this result?
403 Forbidden
400 Bad Request
401 Unauthorized
404 Not Found
52 A POST request fails because a submitted email violates a database uniqueness constraint. Which response most accurately represents the application-level conflict?
201 Created
409 Conflict
204 No Content
503 Service Unavailable
53
An ASP.NET Core API action returns ActionResult<Product> and uses return NotFound(); for a missing product and return product; for a successful lookup. What does this return type enable?
Product response
54
An ASP.NET Core API registers AddControllers() but omits MapControllers() in a minimal hosting configuration. What is the likely result for attribute-routed controllers?
55 A controller action accepts a complex object from the request body and also declares a route parameter with the same property name. What is the safest design to avoid ambiguous binding behavior?
[ApiController] from the controller
56
A controller contains [HttpGet("{id:int}")] and [HttpGet("{name}")] actions. A request arrives at /api/items/12. What is the main purpose of the int constraint?
57
A User entity contains PasswordHash, IsAdmin, and internal audit fields. Why should a response DTO generally be used instead of returning the entity directly?
58
An API receives a PUT request for an existing product, but the payload omits a required property. The server treats PUT as full replacement. What should normally happen?
PATCH
59
A DELETE operation succeeds, removes the resource, and has no representation to return. Which response is most appropriate?
304 Not Modified because deletion is cacheable
204 No Content with no response body
200 OK with the deleted entity required
201 Created with an empty response body
60 An endpoint returns different schemas for successful and error responses, but Swagger UI displays only the success schema. Which change most directly improves the OpenAPI contract?
Did this save you a night before the exam?
LPU Notes is free, and it stays free. Ads cover part of the server bill. The rest comes out of a student's own pocket: the domain, the storage, and keeping the site up through the weeks everyone needs it at once.
The payment button didn't load. An ad blocker or a filtered network is the usual reason. to try again.
Nothing here is ever locked, and nothing unlocks. Chip in only if it was worth it. What it pays for →