Web API MCQs

Web API MCQs

These Web API multiple-choice questions and their answers will help you strengthen your grip on the subject of Web API. You can prepare for an upcoming exam or job interview with these Web API MCQs.
So scroll down and start answering.

1:

You are designing an application that allows employees to change their human resources (HR) information, such as next of kin and direct deposit information. The requirements state that the application should talk directly to the HR systems’ database.

However, at a recent company meeting, the CFO announced that the company will be converting to a new HR system over the next two years. They will take an additional year to move employees to the new system, one department at a time. How will this affect your design?


A.  

It won’t; the requirements state that the application should talk directly to the HR systems’ database.

B.  

You should ensure your naming convention for the database as clearly as possible so you can rework your data calls with minimal changes.


C.  

You should map the model directly to the database calls, anticipating that you will have to change the model as the new system rolls out.

D.  

You should implement the Repository pattern with the current HR system being the first repository that is built. When the second system comes online, you imple­ment that data access using the same pattern.

2:

You are developing an ASP.NET MVC web application in Visual Studio 2012. The application requires several thousand content files. All content is hosted on the same IIS instance as the application. You detect performance issues when the application starts. You need to resolve the performance issues. What should you do?

A.  

Install a second IIS instance.

B.  

Move the content to a Windows Azure CDN.

C.  

Implement HTTP caching in the ASP.NET MVC controllers.

D.  

Combine the content files by using ASP.NET MVC bundling.

3:

Your ASP.NET MVC web application has just been released to a group of pilot users. The users are reporting periods of extreme performance degradation. You did not encounter performance issues during development or the quality assurance phase. What can you do in your development environment to understand what is occurring in the production environment?


A.  

Create a set of unit tests that repeatedly test certain parts of the application. Run them continuously over a period of time to ensure that the application works as expected.


B.  

Create a set of web tests that exercise the application. Set a run load of 50 percent of your pilot users and run them in a constant load testing process to validate the application’s behavior.


C.  

Create a set of web tests that exercise the application. Using a step approach, start with a minimal number of users and increase to the total number of users in the pilot program.


D.  

Create a set of web tests that exercise the application. Using a goal-based approach, set the process to run to 75 percent CPU utilization. When you reach that point, compare the results with the number of users in the pilot program.


4:

You develop an ASP.NET MVC application that is secured by using SSL. You are ready to deploy the application to production. The deployment package must include the installation of the SSL certificate. You need to configure the deployment package to meet the requirement. What should you do?

A.  

In the Build Events settings of the project, configure a pre-build event to include the SSL certificate.


B.  

Extend the CopyAllFilesToSingleFolder target in the project file.


C.  

In the Package/Publish settings of the project, select the All Files in this project option.


D.  

Create a web publish pipeline target file with a custom web deploy target.


5:

You are designing an ASP.NET Web API application. You need to select an HTTP verb to allow blog administrators to moderate a comment. Which HTTP verb should you use?


A.  

GET

B.  

POST

C.  

DELETE

D.  

PUT

6:

You are developing an ASP.NET MVC application that reads and writes data from a SQL Server database. You need to prevent the application from reading data that is locked by other transactions. You also need to prevent exclusive range locks. Which isolation level should you use?


A.  

Serializable


B.  

Repeatable

C.  

Read Committed

D.  

Read Uncommitted


7:

You are planning to migrate websites from IIS 6 to IIS 7.5. You do not have access to SSH or a VPN. You need to select a deployment tool to securely migrate the websites. Which tool should you use?

A.  

RoboCopy

B.  

xCopy

C.  

Web Deploy

D.  

Microsoft command-line FTP

8:

How to ensure that ASP.NET Web API returns only JSON data ?

A.  

contig.Forniatters.)sonForrnatter.SupportedMediaTypes.Add(new  MediaTypeHeaderValue("application/json"));

B.  

config.Formatters.XMLFormatter.SupportedMediaTypes.Add (new MediaTypeHeaderValue('text/html') );


C.  

config.Formatters..JsonFormatter.SupportedMediaTypesAdd (new MediaTypeHeaderValue('text/xml") );


D.  

config.Formatters.XMLFormatter.SupportedMediaTypes.Add (new MediaTypeHeaderValue("text/xml') );


9:

How do you encrypt the <connectionstrings> section of the Web.config file?


A.  

aspnet_regiis -pd "Web.Config" -app "/MachineDPAPI" -prov "RsaProtectedConfigurationProvider"


B.  

aspnet_regiis -pd "ConnectionStrings" -app "/MachineDPAPI" -prov "RsaProtectedConfigurationProvider"

C.  

aspnet_regiis -pe "Web.Config"-app "/MachineDPAPI" -prov "RsaProtectedConfigurationProvider"

D.  

aspnet_regiis -pe "ConnectionStrings" -app "/MachineDPAPI" -prov "RsaProtectedConfigurationProvider"

10:

Your application has an intermittent issue, based on the user’s path through the application, in which the application seems to stop running. Even when running in debug mode, the application calls a web service and then stops. The application locks and the call never returns, thus the user’s request is never completed and eventually times out.

What performance or profiling tool will provide the most pertinent information about your application?


A.  

CPU sampling in the Performance Wizard

B.  

Memory allocation in the Performance Wizard

C.  

Resource contention data in the Performance Wizard

D.  

Tracing from the System. Diagnostics namespace that logs the times of web service call and web service return

11:

You support hardware purchasing for an ASP.NET MVC application in your company. The application is finished, and the development team knows the number of intended users. Which approach will give the team the best understanding of the application’s hardware needs?

A.  

Create several web tests that exercise all parts of the application, including all static pages. Run these tests in a constant load at various levels to see the effect on performance.

B.  

Create several web tests that exercise all parts of the application, including all static pages. Run these tests in a step approach up to the maximum expected number of users. This will give you an idea of the load one server can handle.


C.  

Create several web tests that exercise all parts of the application, including all static pages. Run these tests in a goal-based approach in which the percent of CPU usage and percent of memory usage metrics are set to the company standard maximums. Evaluate how many users it takes to reach the maximum levels.


D.  

Create several web tests that exercise only the dynamic parts of the application, ignoring all static content. Run these tests in a goal-based approach in which the percent of CPU usage and percent of memory usage metrics are set to the company standard maximums. Evaluate how many users it takes to reach these maximum levels.

12:

You need to maximize performance of video delivery. Which code segment should you use as the body of the GetVideoStream function in the VideoController class?

A.  

if (Request.Headers["Accept-Encoding"].Contains("gzip"))

{

return new GZipStream(System.IO.File.OpenRead(videoId),CompressionMode.Compress);

}


B.  

return new GZipStream(System.IO.File.OpenRead(videoId), CompressionMode.Compress);

if (Request.ContentEncoding.BodyName == "application/x-gzip")

{

return new GZipStream(System.IO.File.OpenRead(videoId), CompressionMode.Compress);

}


C.  

Memory stream = new MemoryStream();

new GZipStream(System.IO.File.OpenRead(videoId), CompressionMode.Compress).CopyTo(stream);

return stream;


13:

Which of the following are valid reasons for overriding the Run method?


A.  

Starting and supporting a logging application for use by the Worker role

B.  

Creating an always-running service that periodically makes HTTP calls to other websites to determine their availability

C.  

Creating and starting a messaging service that will work in parallel with the Web role to manage queued messages


D.  

All of the above


E.  

None of the above

14:

What occurs if an unhandled error is fired on a startup task?

A.  

The startup is cancelled and the role does not start.

B.  

The On Stop method automatically runs.

C.  

The startup task goes to the lowest security setting and continues to run, if possible.

D.  

The startup role consumes the error during its load; if there is no event handler configured, it is set to Handled as the task completes.


15:

You are developing an ASP.NET MVC application. The application is deployed in a web farm and is accessed by many users.

The application must handle web server failures gracefully. The servers in the farm must share the short-term state information.

You need to persist the application state during the session. What should you implement?


A.  

A state server

B.  

A local database

C.  

ASP.NET session state

D.  

Profile properties

16: An application programming interface (api) is ________.

A.   The code the application software needs in order to interact with the CPU

B.   The code to interface between an application and a peripheral like a printer

C.   The currently active part of an application

D.   The code to interface between an application and RAM