Unit 6: SQL Server and ASP.NET Core Web API - Practice Quiz

CSE253 — .Net Programming 60 Questions
0 Correct 0 Wrong 60 Left
0/60

1 What is SQL Server primarily used for?

Introduction to SQL Server Easy
A. Creating image animations
B. Editing audio files
C. Managing and storing relational data
D. Designing computer hardware

2 Which SQL command is used to retrieve data from a table?

SQL Commands Easy
A. INSERT
B. SELECT
C. UPDATE
D. DELETE

3 Which SQL command adds a new row to a table?

SQL Commands Easy
A. CREATE
B. INSERT
C. ALTER
D. DROP

4 What does a row in a SQL Server table usually represent?

SQL Server Tables Easy
A. A column definition
B. A table relationship
C. A complete record
D. A database connection

5 What does a column in a table represent?

SQL Server Tables Easy
A. A server login session
B. A complete database
C. A type of data or field
D. A group of databases

6 Which constraint uniquely identifies each row in a table?

Constraints Easy
A. Check constraint
B. Primary key
C. Foreign key
D. Default constraint

7 Which constraint prevents a column from containing NULL values?

Constraints Easy
A. NOT NULL
B. FOREIGN KEY
C. UNIQUE
D. PRIMARY KEY

8 What is the purpose of a SQL join?

Joins Easy
A. To delete a database
B. To combine related data
C. To format a table
D. To rename a server

9 Which join returns matching rows from both tables?

Joins Easy
A. CROSS JOIN
B. FULL JOIN
C. LEFT JOIN
D. INNER JOIN

10 What does REST commonly describe?

Introduction to REST Architecture Easy
A. A programming language compiler
B. An architectural style for web services
C. A database storage format
D. A desktop user interface

11 In REST, resources are commonly identified using what?

Introduction to REST Architecture Easy
A. File extensions
B. URLs
C. Memory addresses
D. CSS classes

12 Which HTTP method is commonly used to retrieve data?

HTTP Protocol and HTTP Methods Easy
A. DELETE
B. GET
C. PUT
D. POST

13 Which HTTP method is commonly used to create a new resource?

HTTP Protocol and HTTP Methods Easy
A. HEAD
B. POST
C. GET
D. PATCH

14 What does HTTP status code 200 OK indicate?

HTTP Status Codes Easy
A. The request succeeded
B. The resource was deleted
C. The request was unauthorized
D. The server was not found

15 What does HTTP status code 404 Not Found mean?

HTTP Status Codes Easy
A. The server created a resource
B. The resource was not found
C. The request succeeded
D. The client was authenticated

16 What is ASP.NET Core Web API used to build?

Introduction to ASP.NET Core Web API Easy
A. Operating system kernels
B. Web-based APIs
C. Image compression tools
D. Spreadsheet templates

17 What is the main role of an API controller?

API Controllers Easy
A. Store database backups
B. Compile CSS files
C. Handle HTTP requests
D. Manage computer drivers

18 What does routing determine in a Web API?

Routing using Convention and Attribute Routing Easy
A. Which password is required
B. Which controller handles a request
C. Which database is installed
D. Which browser is running

19 What is the main purpose of a DTO?

Data Transfer Objects (DTOs) Easy
A. Transfer selected data
B. Create database indexes
C. Encrypt every network packet
D. Start the web server

20 What does the letter D represent in CRUD?

CRUD Operations using Web API Easy
A. Describe
B. Deploy
C. Download
D. Delete

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?

Introduction to SQL Server Medium
A. Database Engine
B. SQL Server Agent
C. Integration Services
D. Reporting Services

22 Which SQL statement correctly increases the salary by 10% for employees in department 3?

SQL Commands Medium
A. UPDATE Employees SET Salary = Salary * 1.10 WHERE DepartmentId = 3;
B. ALTER Employees SET Salary = Salary + 10 WHERE DepartmentId = 3;
C. CHANGE Employees Salary TO Salary * 1.10;
D. MODIFY Employees Salary BY 10% WHERE DepartmentId = 3;

23 A table named Orders must store an automatically generated integer identifier for every order. Which column definition is most appropriate?

SQL Server Tables Medium
A. OrderId VARCHAR(20)
B. OrderId INT IDENTITY(1,1)
C. OrderId DATE DEFAULT GETDATE()
D. 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?

Constraints Medium
A. A CHECK constraint on the enrollment date
B. A DEFAULT constraint on CourseId
C. A NOT NULL constraint on the enrollment status
D. A composite UNIQUE constraint on StudentId and CourseId

25 The Orders.CustomerId column references Customers.CustomerId. What is the main purpose of this foreign key constraint?

Constraints Medium
A. To enforce referential integrity
B. To sort orders by customer
C. To generate a new customer identifier for each order
D. To automatically encrypt customer data

26 A report must list every department, including departments that currently have no employees. Which join should be used between Departments and Employees?

Joins Medium
A. LEFT JOIN from Departments to Employees
B. RIGHT JOIN from Employees to Departments
C. INNER JOIN from Departments to Employees
D. CROSS JOIN from Departments to Employees

27 Which query returns customers who have placed at least one order, without requiring customers with no orders to appear?

Joins Medium
A. SELECT c.Name FROM Customers c CROSS JOIN Orders o;
B. SELECT c.Name FROM Customers c RIGHT JOIN Orders o ON c.Id IS NULL;
C. SELECT c.Name FROM Customers c INNER JOIN Orders o ON c.Id = o.CustomerId;
D. SELECT c.Name FROM Customers c LEFT JOIN Orders o ON c.Id <> o.CustomerId;

28 Which design best follows REST principles for retrieving a product with identifier 42?

Introduction to REST Architecture Medium
A. Send GET /api/products/42
B. Send POST /getProduct?id=42
C. Send POST /api/products with a body containing only the identifier and an instruction to retrieve the product
D. Send GET /api/getProductAction/42

29 A REST API is described as stateless. What does this mean for requests?

Introduction to REST Architecture Medium
A. Each request contains the information needed to process it
B. The server stores every client request permanently
C. The server can process requests only in their original order
D. The client must use the same connection for all requests

30 A client sends PUT /api/products/7 with a complete replacement representation of product 7. Which behavior is normally associated with PUT?

HTTP Protocol and HTTP Methods Medium
A. Replace or create the resource at the specified URI
B. Execute a server-side query without identifying a resource
C. Partially modify only one selected property
D. Retrieve the current representation without changing it

31 Which HTTP method is most appropriate for partially updating only the email address of an existing user?

HTTP Protocol and HTTP Methods Medium
A. GET
B. PATCH
C. POST
D. HEAD

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?

HTTP Status Codes Medium
A. 204 No Content
B. 200 OK
C. 304 Not Modified
D. 201 Created

33 A client sends valid JSON to an endpoint, but the requested product identifier does not exist. Which response status is most appropriate?

HTTP Status Codes Medium
A. 404 Not Found
B. 500 Internal Server Error
C. 401 Unauthorized
D. 400 Bad Request

34 Which ASP.NET Core service is commonly registered to allow controllers to handle HTTP API requests?

Introduction to ASP.NET Core Web API Medium
A. UseStaticFiles()
B. AddSqlServer()
C. AddControllers()
D. AddRazorPagesOnly()

35 In a typical ASP.NET Core Web API application, why is app.MapControllers() required when attribute-routed controllers are used?

Building and Configuring Web APIs Medium
A. It serializes every request into XML
B. It maps controller endpoints into the request pipeline
C. It creates the SQL Server database schema
D. It automatically generates DTO classes from entities

36 What is the main benefit of deriving an ASP.NET Core API controller from ControllerBase instead of Controller?

API Controllers Medium
A. It enables Razor view rendering by default
B. It automatically creates database tables
C. It provides API-focused features without view support
D. It prevents the controller from returning JSON

37 Given the route template [Route("api/[controller]")] and an action marked [HttpGet("{id:int}")] in ProductsController, which URL matches the action?

Routing using Convention and Attribute Routing Medium
A. GET /Products/api/12
B. GET /api/Products/12
C. GET /api/Product?id=12
D. POST /api/Products/12

38 A User entity contains PasswordHash, but the API should return only Id, Name, and Email. What is the best approach?

Data Transfer Objects (DTOs) Medium
A. Rename PasswordHash to make it less recognizable
B. Return a response DTO containing only safe fields
C. Return the entity and rely on clients to ignore the password hash
D. Store the password hash in a query-string parameter instead

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?

CRUD Operations using Web API Medium
A. CreatedAtAction with the created product
B. Unauthorized with the product identifier
C. NoContent without any response headers
D. BadRequest because POST cannot return a resource

40 What is a practical benefit of adding Swagger/OpenAPI to an ASP.NET Core Web API?

Swagger/OpenAPI Documentation Medium
A. It automatically authenticates every API consumer
B. It replaces SQL Server with an in-memory database
C. It documents endpoints and enables interactive testing
D. It guarantees that all controller actions are free of errors

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?

Introduction to SQL Server Hard
A. Committed changes from earlier transactions are undone
B. The transaction remains pending until the server restarts
C. Only the last failed statement is undone
D. All changes in the transaction are undone

42 A developer executes DELETE FROM Orders without a WHERE clause inside an explicit transaction. Which statement is most accurate?

SQL Commands Hard
A. The command deletes only rows selected by the current user
B. The command is rejected unless the table has a primary key
C. The command removes the table structure and all metadata
D. The command marks every row for deletion until commit

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?

SQL Server Tables Hard
A. A clustered index on CustomerId alone
B. A composite primary key on CustomerId and ProductId
C. A foreign key from UnitPrice to the product table
D. A unique constraint on Quantity and UnitPrice

44 A nullable column has a UNIQUE constraint in SQL Server. Which behavior should an application generally account for?

Constraints Hard
A. Only one null value is generally permitted
B. A null value bypasses the uniqueness comparison
C. Null values are treated as identical text values
D. Every null value is always rejected

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?

Joins Hard
A. An inner join from departments to employees
B. A left outer join from departments to employees
C. A cross join between departments and employees
D. A right outer join from departments to employees

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?

Joins Hard
A. The query automatically removes duplicate item rows
B. The join can multiply rows and inflate aggregates
C. The database converts the join into a subquery
D. The grouping forces all item prices to become identical

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?

Introduction to REST Architecture Hard
A. Cache invalidation
B. Server-controlled session state
C. Idempotent request semantics
D. Client-side rendering

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?

Introduction to REST Architecture Hard
A. Uniform interface through hypermedia controls
B. Elimination of HTTP content negotiation
C. Mandatory server-side session persistence
D. Exclusive use of XML resource representations

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?

HTTP Protocol and HTTP Methods Hard
A. 201 Created with the resource location
B. 409 Conflict because PUT cannot create resources
C. 200 OK with no response body
D. 204 No Content with validation errors

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?

HTTP Protocol and HTTP Methods Hard
A. 304 Not Modified without the representation body
B. 201 Created with a replacement representation
C. 412 Precondition Failed for every matching tag
D. 200 OK with the complete representation

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?

HTTP Status Codes Hard
A. 403 Forbidden
B. 404 Not Found
C. 401 Unauthorized
D. 400 Bad Request

52 A POST request fails because a submitted email violates a database uniqueness constraint. Which response most accurately represents the application-level conflict?

HTTP Status Codes Hard
A. 201 Created
B. 204 No Content
C. 409 Conflict
D. 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?

Introduction to ASP.NET Core Web API Hard
A. Typed success results plus other HTTP results
B. Only status codes without response bodies
C. Automatic database transactions for the action
D. Only a serialized 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?

Building and Configuring Web APIs Hard
A. Dependency injection is disabled for all controller services
B. Controllers are discovered and endpoints are mapped automatically
C. Only Swagger endpoints are exposed and controllers are deleted
D. Controller services exist, but their routes are not exposed

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?

API Controllers Hard
A. Use separate names and explicit binding sources
B. Declare multiple body-bound parameters
C. Convert the complex object into a route token
D. Remove [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?

Routing using Convention and Attribute Routing Hard
A. It permits both actions to execute for the request
B. It restricts the first route to integer-shaped values
C. It makes the name action execute before the ID action
D. It converts every route value into an integer

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?

Data Transfer Objects (DTOs) Hard
A. DTOs prevent every form of SQL injection automatically
B. DTOs force all database columns to be indexed
C. DTOs limit exposed data and decouple the API contract
D. DTOs eliminate the need for response serialization

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?

CRUD Operations using Web API Hard
A. A second product is created with default values
B. The omitted property is silently preserved
C. The omitted property is set according to replacement rules
D. The request is treated as a partial PATCH

59 A DELETE operation succeeds, removes the resource, and has no representation to return. Which response is most appropriate?

CRUD Operations using Web API Hard
A. 200 OK with the deleted entity required
B. 204 No Content with no response body
C. 201 Created with an empty response body
D. 304 Not Modified because deletion is cacheable

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?

Swagger/OpenAPI Documentation Hard
A. Replace all error responses with status code 200
B. Add response metadata for each status code and schema
C. Disable content negotiation for the endpoint
D. Rename the controller to match the database table