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. Designing computer hardware
D. Managing and storing relational data

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

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

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

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

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

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

5 What does a column in a table represent?

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

6 Which constraint uniquely identifies each row in a table?

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

7 Which constraint prevents a column from containing NULL values?

Constraints Easy
A. NOT NULL
B. PRIMARY KEY
C. UNIQUE
D. FOREIGN 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. INNER JOIN
C. LEFT JOIN
D. FULL 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 desktop user interface
D. A database storage format

11 In REST, resources are commonly identified using what?

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

12 Which HTTP method is commonly used to retrieve data?

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

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

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

14 What does HTTP status code 200 OK indicate?

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

15 What does HTTP status code 404 Not Found mean?

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

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

Introduction to ASP.NET Core Web API Easy
A. Operating system kernels
B. Image compression tools
C. Web-based APIs
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. Manage computer drivers
D. Handle HTTP requests

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 browser is running
D. Which database is installed

19 What is the main purpose of a DTO?

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

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. Reporting Services
B. Database Engine
C. SQL Server Agent
D. Integration Services

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

SQL Commands Medium
A. CHANGE Employees Salary TO Salary * 1.10;
B. ALTER Employees SET Salary = Salary + 10 WHERE DepartmentId = 3;
C. MODIFY Employees Salary BY 10% WHERE DepartmentId = 3;
D. UPDATE Employees SET Salary = Salary * 1.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 DATE DEFAULT GETDATE()
B. OrderId INT IDENTITY(1,1)
C. OrderId VARCHAR(20)
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 NOT NULL constraint on the enrollment status
B. A composite UNIQUE constraint on StudentId and CourseId
C. A CHECK constraint on the enrollment date
D. A DEFAULT constraint on CourseId

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

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

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. RIGHT JOIN from Employees to Departments
B. INNER JOIN from Departments to Employees
C. LEFT 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 LEFT JOIN Orders o ON c.Id <> o.CustomerId;
B. SELECT c.Name FROM Customers c CROSS JOIN Orders o;
C. SELECT c.Name FROM Customers c INNER JOIN Orders o ON c.Id = o.CustomerId;
D. SELECT c.Name FROM Customers c RIGHT JOIN Orders o ON c.Id IS NULL;

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

Introduction to REST Architecture Medium
A. Send POST /getProduct?id=42
B. Send POST /api/products with a body containing only the identifier and an instruction to retrieve the product
C. Send GET /api/products/42
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 client must use the same connection for all requests
C. The server stores every client request permanently
D. The server can process requests only in their original order

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. Execute a server-side query without identifying a resource
B. Retrieve the current representation without changing it
C. Partially modify only one selected property
D. Replace or create the resource at the specified URI

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. POST
B. HEAD
C. PATCH
D. GET

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. 304 Not Modified
B. 200 OK
C. 201 Created
D. 204 No Content

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. 400 Bad Request
B. 401 Unauthorized
C. 500 Internal Server Error
D. 404 Not Found

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. AddRazorPagesOnly()
B. UseStaticFiles()
C. AddControllers()
D. AddSqlServer()

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 automatically creates database tables
B. It enables Razor view rendering by default
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. POST /api/Products/12
B. GET /api/Products/12
C. GET /api/Product?id=12
D. 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?

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

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. Unauthorized with the product identifier
B. NoContent without any response headers
C. CreatedAtAction with the created product
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 documents endpoints and enables interactive testing
B. It guarantees that all controller actions are free of errors
C. It automatically authenticates every API consumer
D. It replaces SQL Server with an in-memory database

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. All changes in the transaction are undone
C. The transaction remains pending until the server restarts
D. Only the last failed statement is 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 removes the table structure and all metadata
C. The command marks every row for deletion until commit
D. The command is rejected unless the table has a primary key

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 composite primary key on CustomerId and ProductId
B. A unique constraint on Quantity and UnitPrice
C. A clustered index on CustomerId alone
D. A foreign key from UnitPrice to the product table

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

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

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. A left outer join from departments to employees
B. An inner 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 database converts the join into a subquery
B. The join can multiply rows and inflate aggregates
C. The query automatically removes duplicate item rows
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. Client-side rendering
B. Cache invalidation
C. Idempotent request semantics
D. Server-controlled session state

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. Exclusive use of XML resource representations
B. Elimination of HTTP content negotiation
C. Mandatory server-side session persistence
D. Uniform interface through hypermedia controls

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. 204 No Content with validation errors
C. 409 Conflict because PUT cannot create resources
D. 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?

HTTP Protocol and HTTP Methods Hard
A. 200 OK with the complete representation
B. 304 Not Modified without the representation body
C. 201 Created with a replacement representation
D. 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?

HTTP Status Codes Hard
A. 403 Forbidden
B. 400 Bad Request
C. 401 Unauthorized
D. 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?

HTTP Status Codes Hard
A. 201 Created
B. 409 Conflict
C. 204 No Content
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. Only a serialized Product response
B. Automatic database transactions for the action
C. Only status codes without response bodies
D. Typed success results plus other HTTP results

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. Only Swagger endpoints are exposed and controllers are deleted
C. Controllers are discovered and endpoints are mapped automatically
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. Declare multiple body-bound parameters
B. Remove [ApiController] from the controller
C. Convert the complex object into a route token
D. Use separate names and explicit binding sources

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 converts every route value into an integer
B. It permits both actions to execute for the request
C. It makes the name action execute before the ID action
D. It restricts the first route to integer-shaped values

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 limit exposed data and decouple the API contract
C. DTOs force all database columns to be indexed
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 request is treated as a partial PATCH
C. The omitted property is silently preserved
D. The omitted property is set according to replacement rules

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. 304 Not Modified because deletion is cacheable
B. 204 No Content with no response body
C. 200 OK with the deleted entity required
D. 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?

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