C# - C Sharp: PRN232 - PT1


Khóa học qua video:
Lập trình Python All Lập trình C# All SQL Server All Lập trình C All Java PHP HTML5-CSS3-JavaScript
Đăng ký Hội viên
Tất cả các video dành cho hội viên

(nhấn nút 'Result' để biết kết quả)

Q1: What is the main purpose of a model in ASP.NET Core Web API?
To represent application data and business concepts
To configure the web server
To manage browser cookies only
To compile JavaScript code

Q2: Which C# keyword is commonly used to define a model class?
model
class
object
entity

Q3: Which property type is most appropriate for storing a person's age?
string
int
DateTime
bool

Q4: Which C# type is commonly used for a unique identifier represented as a GUID?
Guid
int
double
char

Q5: What does a nullable property such as int? Age allow?
Only negative values
Only zero values
An integer value or null
Only string values

Q6: Which attribute is commonly used to specify that a model property is required?
[Required]
[Mandatory]
[NotNull]
[Important]

Q7: Which namespace contains the RequiredAttribute used for model validation?
System.IO
System.ComponentModel.DataAnnotations
System.Net
System.Linq

Q8: What is model validation used for in Web API?
To validate incoming data
To compile controllers
To create database servers
To encrypt HTTP headers

Q9: Which attribute can specify a maximum string length in a model?
[Maximum]
[StringLimit]
[LengthLimit]
[MaxLength]

Q10: Which attribute is commonly used to validate an email address?
[EmailAddress]
[Email]
[Mail]
[EmailFormat]

Q11: What is a DTO in ASP.NET Core Web API?
Database Table Object
Data Transaction Operation
Data Transfer Object
Default Type Object

Q12: Why are DTOs commonly used in Web APIs?
To replace HTTP
To control the data exposed by an API
To compile C# automatically
To create CSS files

Q13: Which property declaration represents a string property named Name?
public string Name { get; set; }
string public Name();
Name string { get; set; }
property string Name;

Q14: What does the get accessor of an auto-property do?
Sets a value
Retrieves a value
Deletes the property
Validates the controller

Q15: What does the set accessor of an auto-property do?
Retrieves a value
Sets a value
Creates a database
Serializes JSON

Q16: Which attribute can be used to specify a range for a numeric model property?
[Range]
[NumberRange]
[Between]
[Numeric]

Q17: What does the [StringLength] attribute provide?
Database encryption
HTTP routing
JSON compression
String length validation

Q18: Which attribute can provide a custom validation error message?
[Message("Name is required")]
[Required(ErrorMessage = "Name is required")]
[Error("Name is required")]
[ValidationMessage("Name is required")]

Q19: What is model binding in ASP.NET Core Web API?
The process of compiling C# classes
The process of creating SQL indexes
The process of mapping HTTP data to action parameters or models
The process of starting IIS

Q20: Which attribute explicitly indicates that a parameter should come from the request body?
[FromBody]
[FromRequest]
[Body]
[RequestBody]

Q21: Which attribute indicates that a value should be read from the route?
[FromPath]
[RouteValue]
[FromUrl]
[FromRoute]

Q22: Which attribute indicates that a value should be read from the query string?
[FromQuery]
[Query]
[FromUrl]
[QueryValue]

Q23: What does this model represent? public class Product { public int Id { get; set; } public string Name { get; set; } }
A controller
A middleware component
A product with an ID and name
A database connection

Q24: Which HTTP method is commonly used to create a resource using a model?
GET
POST
DELETE
HEAD

Q25: Which HTTP method is commonly used to retrieve a resource?
POST
GET
PATCH
DELETE

Q26: Which HTTP method is commonly associated with completely updating a resource?
GET
POST
PUT
HEAD

Q27: Which HTTP method is commonly used for partially updating a resource?
PATCH
GET
HEAD
OPTIONS

Q28: Which HTTP method is commonly used to delete a resource?
POST
GET
DELETE
PUT

Q29: What does IActionResult allow a controller action to return?
Different types of HTTP responses
Only strings
Only database records
Only JSON arrays

Q30: Which result is commonly used to return an object as an HTTP 200 response?
Ok()
Created()
NotFound()
BadRequest()

Q31: Which result represents an HTTP 404 response?
Ok()
NotFound()
Created()
Accepted()

Q32: Which result represents an HTTP 400 response?
Ok()
BadRequest()
Created()
NoContent()

Q33: Which result is commonly used after successfully creating a resource?
Created()
NotFound()
BadRequest()
Unauthorized()

Q34: What is the purpose of a response model?
To define data returned by an API
To define server hardware
To configure DNS
To compile the application

Q35: Why should sensitive properties sometimes be excluded from DTOs?
To increase CPU speed
To disable routing
To remove HTTP
To prevent exposing sensitive information

Q36: What is over-posting in a Web API?
When a client submits properties it should not be allowed to modify
When the server receives no data
When JSON is compressed
When a GET request is cached

Q37: How can DTOs help prevent over-posting?
By disabling JSON
By disabling HTTP
By exposing only allowed properties
By removing controllers

Q38: Which attribute can prevent a property from being included during JSON serialization in System.Text.Json?
[IgnoreJson]
[JsonIgnore]
[NoJson]
[ExcludeJson]

Q39: What is a model class with navigation properties commonly used to represent?
Relationships between entities
HTTP status codes
Browser cookies
URL encoding

Q40: Which approach is generally recommended for APIs when database entities contain fields that should not be exposed?
Expose every entity property
Disable validation
Use only primitive parameters
Use DTOs

Q41: What is the main purpose of a media formatter in ASP.NET Core Web API?
To serialize and deserialize HTTP content
To create database tables
To manage user passwords
To compile controllers

Q42: Which format is commonly used as the default response format in ASP.NET Core Web API?
CSV
JSON
XML
HTML

Q43: Which component is commonly used for JSON serialization in modern ASP.NET Core?
System.Text.Xml
System.JsonNet.Core
System.Text.Json
System.Web.Json

Q44: What does serialization mean in a Web API?
Converting HTTP into TCP
Converting an object into a transferable format
Deleting an object
Compiling a model

Q45: What does deserialization mean?
Converting formatted data into an object
Deleting JSON
Creating an HTTP server
Compressing an image

Q46: Which HTTP header specifies the media type of the request body?
Accept
Host
User-Agent
Content-Type

Q47: Which HTTP header indicates the response media types preferred by the client?
Content-Type
Host
Origin
Accept

Q48: What does content negotiation determine?
The database password
The representation format used for a response
The controller class name
The server operating system

Q49: Which value commonly represents JSON in an HTTP Content-Type header?
text/json-data
application/data
application/json
json/application

Q50: Which value commonly represents XML?
application/xml
application/x-json
text/json
xml/data

Q51: If a client sends Accept: application/json, what does it request?
An XML request body
A JSON response
A file upload
A redirect

Q52: If a client sends Content-Type: application/json, what does it indicate?
The request body contains JSON
The response must be XML
The request is a GET request
The server uses OData

Q53: Which service can be used to configure JSON serialization options?
AddJsonOptions
UseJsonSettings
ConfigureJsonService
EnableJson

Q54: Which method is commonly used to register controllers in ASP.NET Core?
RegisterControllers()
UseControllers()
EnableControllers()
AddControllers()

Q55: Which method is commonly used to add XML formatters to MVC controllers?
UseXmlFormatters()
AddXmlSerializerFormatters()
AddXmlControllers()
EnableXmlSerializer()

Q56: What is the purpose of an XML formatter?
To serialize and deserialize XML
To execute SQL
To validate passwords
To manage routes

Q57: What happens when a formatter serializes an object?
The object is deleted
The controller is removed
The object is converted into a response representation
The database is restarted

Q58: Which header is primarily involved in response content negotiation?
Content-Length
Accept
Authorization
Referer

Q59: Which header is primarily involved in request body format selection?
Content-Type
Accept
Host
Location

Q60: What does the Accept header contain?
Media types acceptable to the client
The request body
The user's password
The server's IP address

Q61: What is a media type also commonly called?
SQL type
MIME type
C# type
Route type

Q62: Which media type represents plain text?
application/plain
text/data
plain/text-data
text/plain

Q63: What does the wildcard media type */* in an Accept header mean?
Any media type is acceptable
Only JSON is acceptable
Only XML is acceptable
No media type is acceptable

Q64: What does application/json; charset=utf-8 indicate?
XML using UTF-8
HTML using ASCII
JSON content using UTF-8 character encoding
Binary content

Q65: What is the main benefit of content negotiation?
Clients can request representations in supported formats
Clients can execute server code
Servers can avoid HTTP
It replaces authentication

Q66: Which result may occur if no formatter can satisfy the requested response format?
406 Not Acceptable
201 Created
301 Moved Permanently
204 No Content

Q67: Which status code commonly indicates that the request body format cannot be processed?
200 OK
415 Unsupported Media Type
302 Found
304 Not Modified

Q68: What is input formatting in Web API?
Serializing response objects
Creating routes
Generating HTML pages
Deserializing request data into objects

Q69: What is output formatting?
Reading SQL tables
Reading request headers only
Serializing objects into response data
Creating controllers

Q70: Which formatter is responsible for converting JSON request data into a C# object?
JSON input formatter
XML output formatter
Route formatter
HTML formatter

Q71: Which formatter converts a C# object into JSON response data?
JSON output formatter
XML input formatter
Route formatter
HTML input formatter

Q72: What does [Produces("application/json")] indicate?
The action accepts only XML input
The action requires authentication
The action produces JSON
The action uses OData

Q73: What does [Consumes("application/json")] indicate?
The action returns only XML
The action returns an image
The action disables model binding
The action expects JSON input

Q74: Which attribute can specify the response media type of an action?
[Returns]
[Produces]
[ResponseType]
[Media]

Q75: Which attribute can specify the accepted request media type?
[Consumes]
[Accepts]
[RequestType]
[InputFormat]

Q76: What does a quality value such as q=0.8 in an Accept header represent?
A JSON version
A preference weight
A security level
A response status

Q77: If a client sends Accept: application/xml, what should the API attempt to return?
XML
JSON only
CSV only
HTML only

Q78: What is the purpose of custom formatters?
To replace C#
To support custom media representations
To create database schemas
To disable HTTP

Q79: Which interface can be implemented to create a custom output formatter?
ICustomFormatterOnly
IResponseFormatterService
IHttpOutput
IOutputFormatter

Q80: Which interface can be implemented to create a custom input formatter?
IRequestFormatterOnly
IHttpInput
IModelFormatterService
IInputFormatter

Q81: What does OData stand for?
Object Data Transfer
Open Database Technology
Object Database Protocol
Open Data Protocol

Q82: What is the main purpose of OData?
To replace C#
To provide standardized querying of data over HTTP
To create HTML pages
To manage server hardware

Q83: Which NuGet package is commonly used to add OData support to ASP.NET Core?
Microsoft.Web.OData.Core
Microsoft.AspNetCore.OData
System.AspNet.OData
Microsoft.OData.AspNet

Q84: Which OData query option is used to filter data?
$where
$filter
$find
$condition

Q85: Which OData query option is used to sort data?
$sort
$order
$orderby
$sortby

Q86: Which OData query option is used to limit the number of returned records?
$top
$limit
$take
$count

Q87: Which OData query option is used to skip a number of records?
$offset
$ignore
$jump
$skip

Q88: Which OData query option requests the number of matching records?
$total
$size
$count
$number

Q89: Which OData query option is used to select specific properties?
$fields
$properties
$select
$columns

Q90: Which OData query option is used to expand related entities?
$include
$join
$expand
$related

Q91: What does the URL /odata/Products?$top=10 request?
The last 10 products
The first 10 products
All products sorted by price
Only products named 10

Q92: What does /odata/Products?$skip=20 mean?
Return exactly 20 products
Skip the last 20 products
Skip the first 20 products
Sort by 20

Q93: What does /odata/Products?$filter=Price gt 100 mean?
Return products whose price is less than 100
Sort products by price
Return exactly 100 products
Return products whose price is greater than 100

Q94: Which OData operator means "greater than"?
greater
more
above
gt

Q95: Which OData operator means "less than"?
less
lt
below
under

Q96: Which OData operator means "equal to"?
eq
equals
same
equal

Q97: Which OData operator means "not equal to"?
ne
neq
not
different

Q98: Which OData operator represents logical AND?
&&
AND
and
both

Q99: Which OData operator represents logical OR?
or
||
OR
either

Q100: What does /odata/Products?$orderby=Price desc do?
Sorts products by price ascending
Filters prices below zero
Returns only one product
Sorts products by price descending

Q101: What does the asc keyword mean in OData?
Descending order
Filtering
Ascending order
Grouping

Q102: What does the desc keyword mean in OData?
Ascending order
Descending order
Filtering
Selecting

Q103: Which attribute is commonly used to enable OData query processing on an action?
[EnableQuery]
[ODataQuery]
[EnableOData]
[QueryEnabled]

Q104: Which namespace commonly contains EnableQueryAttribute?
Microsoft.AspNetCore.OData.Query
Microsoft.AspNetCore.OData.Model
Microsoft.AspNetCore.OData.Controllers
Microsoft.AspNetCore.Query.OData

Q105: What does [EnableQuery] allow clients to do?
Execute arbitrary C# code
Modify server configuration
Access private fields
Apply supported OData query options

Q106: Which return type is commonly suitable for an OData-enabled collection query?
Console
Thread
Stream
IQueryable

Q107: Why can IQueryable be useful with OData?
It disables filtering
Queries can potentially be translated and executed by the data provider
It converts all data to XML
It prevents database access

Q108: What is an OData Entity Data Model (EDM)?
A model describing entities and their relationships
A C# compiler
An HTTP client
A database password

Q109: Which builder is commonly used to construct an OData EDM model?
ODataEntityBuilder
ODataSchemaBuilder
ODataConventionModelBuilder
ODataModelCreator

Q110: What does ODataConventionModelBuilder primarily use?
SQL scripts
HTML templates
XML configuration files only
Conventions to build the EDM

Q111: Which method is commonly used to register an OData route in ASP.NET Core?
AddRouteComponents
RegisterODataRoute
UseODataRouteOnly
MapODataControllerOnly

Q112: Which service registration is commonly used to configure OData services?
AddOData
UseODataServices
RegisterODataOnly
ConfigureODataServer

Q113: Which code enables common OData query options?
AddOData().EnableEverything()
AddOData().Select().Filter().OrderBy().Expand().Count()
UseOData().AllQueries()
EnableOData().All()

Q114: Which query option is used to retrieve related entities in an OData response?
$related
$include
$expand
$join

Q115: What does $select=Name,Price do?
Filters products by name
Sorts by Name and Price
Returns only two products
Returns only Name and Price properties

Q116: What does $filter=Price ge 50 mean?
Price is less than 50
Price is greater than or equal to 50
Price equals exactly 50
Price is greater than 50 only

Q117: Which OData operator means "greater than or equal to"?
gte
greaterEqual
ge
eqgreater

Q118: Which OData operator means "less than or equal to"?
lte
lessEqual
eqless
le

Q119: What is one important security consideration when enabling OData query options?
Allow every query without restrictions
Disable authentication
Limit and validate query capabilities
Expose database credentials

Q120: Which combination is commonly used to implement an OData-enabled ASP.NET Core Web API?
Microsoft.AspNetCore.OData, EDM model, OData route components, and [EnableQuery]
Only System.Console and SQL Server
Only JavaScript and HTML
Only Entity Framework migrations

(Ghi chú: Phần câu hỏi Qi có màu Green thể hiện đáp án đúng)

(Ghi chú: Phần câu hỏi Qi có màu Green thể hiện đáp án đúng)
» Tiếp: Bài làm mẫu 1
« Trước: Quiz
Khóa học qua video:
Lập trình Python All Lập trình C# All SQL Server All Lập trình C All Java PHP HTML5-CSS3-JavaScript
Đăng ký Hội viên
Tất cả các video dành cho hội viên
Copied !!!