MVC Framework Mock Test



This section presents you various set of Mock Tests related to MVC Framework Framework. You can download these sample mock tests at your local machine and solve offline at your convenience. Every mock test is supplied with a mock test key to let you verify the final score and grade yourself.

Questions and Answers

MVC Framework Mock Test II

Q 1 - You are creating an ASP.NET MVC web application. The application must accept user input for a ProductName field. To reduce delays due to invalid entries making round trips between the client and server, user input should be validated on the client before being submitted to the server. Which code segment should you choose?

A -

@Html.LabelFor(model ⇒ model.ProductName)
@Html.EditorFor(model ⇒ model.ProductName)

B -

@Html.LabelFor(model ⇒ model.ProductName)
@Html.ValidationMessageFor (model ⇒ model.ProductName)

C -

@Html.EditorFor(model ⇒ model.ProductName)@Html.ValidationMessageFor(model⇒model.ProductName)

D -

@Html.LabelFor(model ⇒ model.ProductName)

E - C and A both

F - All of the above

Answer : C

Explanation

C.@Html.EditorFor, in combination with @Html.ValidationMessageFor, are used for client-side validation.

Q 2 - Your team is building an application and you are reviewing the functional specifications. Your team must include a stockticker in the UI that displays the companys stock price every 15 minutes, and include the capability to do partial saves of base objects as users step through a data entry wizard. You want to use the same approach for both requirements to make it easier to add functionality and maintain it going forward. What approach should you use?

A - Use JavaScript to refresh the page every 15 minutes and to manage whether wizard buttons are enabled or disabled.

B - Use AJAX to make asynchronous calls to the server on a timer for the stock price and to automatically save the base objects as the user navigates through the wizard.

C - Use jQuery to refresh the page every 15 minutes and to manage whether wizard buttons are enabled or disabled.

D - Use data validation annotations on the model to ensure that the stock price is validated every 15 minutes and that the client saves the base object information after every wizard step.

E - C and A both

F - All of the above

Answer : B

Explanation

B.The best way to solve this issue is to use AJAX to do asynchronous calls to check the stock price as well as manage the save process through the wizard.

Answer : F

Explanation

F.You should build in validation to check that at least one field has been populated before saving an entry.Although the partner company has not provided any requirements, your company is responsible for data entry and therefore should ensure that the data passing through the application meets some minimum criteria.The application has many entry fields so it is difficult to predict when an entry hits a valid stage. However, you already know you have constraints on the data being input because of the size of the database columns in which you will be storing them. A MaxLength validator on each field would help ensure that there is no loss of data.Although either field in the form can be anything, they should have a maximum length limit imposed so the data does not exceed the size of the database column they will be stored in. You should also validate that neither field is empty.

Q 4 - You are creating an ASP.NET MVC web application. Within the application, you have created a partial view for contact email and phone number. Which code segment should you use to display the partial view on the main page?

A - @Html.ActionLink("ContactPartial")

B - @Html.Partial("ContactPartial")

C - @RenderPage("ContactPartial")

D - @RenderBody()

E - C and A both

F - All of the above

Answer : B

Explanation

B.@Html.Partial loads a partial view.

Q 5 - You are creating an ASP.NET MVC web application. The application accepts phone number input through the applications form. When viewing the source from a browser, you find the following code:

PhoneNumber: <input id="text1" name="phoneNumber" size="10" type="text" value="" />
What Razor syntax code segment was used?

A - PhoneNumber: <input id="phoneNumber" name="phoneNumber" size="10" type="text" value="3125551212" />

B - @Html.EditorFor(model → model.PhoneNumber)

C - PhoneNumber: @Html.TextBox("phoneNumber", Request["phoneNumber"], new { @ placeholder = "3125551212"})

D - PhoneNumber: @Html.TextBox("phoneNumber", Request["phoneNumber"], new { size = 10 })

E - C and A both

F - All of the above

Answer : D

Explanation

D.This is the proper way to limit the size of a certain field that is being bound to the model.

Q 6 - You are modifying an ASP.NET MVC web application and you have created a new master layout page named _Layout.WindowsPhone.cshtml. You want to use that layout in a new view. Which code segment do you use?

A - @Html.ActionLink("_Layout.WindowsPhone.cshtml");

B - Layout="~/Views/Shared/_Layout.WindowsPhone.cshtml";

C - Layout="Layout.WindowsPhone.cshtml";

D - @Html.Partial("_Layout.WindowsPhone.cshtml");

E - C and A both

F - All of the above

Answer : B

Explanation

B.Layout="" loads the layout file to be used with that view.

Q 7 - You want to support the Internet Explorer, Firefox, and Opera web browsers in your application. Which vendor-specific extensions do you need to include with CSS3 properties? (Choose all that apply.)

A - webkit-

B - ms

C - o

D - hp

E - moz

F - B , D and E

Answer : E

Explanation

E.The -ms- prefix is used for Internet Explorer. The -o- prefix is used for the Opera browser.The -moz- prefix is used for Mozilla Firefox.

Answer : E

Explanation

E.Using JavaScript to query the userAgent gives you information about the type of browser being used by the client.The display mode provider performs some of the analysis of the HTTP request to try and determine what kind of browser made the request.

Answer : B

Explanation

B.Adding a DisplayModeProvider for each type of special view, such as IEMobile or IPad, informs the framework to use those views where the context condition is fulfilled.

Q 10 - You are creating an ASP.NET MVC web application, and you decide to create a new layout for mobile devices with relatively small screens. Which @media query should you create or modify to accomplish the task? (Choose all that apply.)

A - @media(max-width:768px)

B - @media (max-width:478px) and (orientation:portrait)

C - @media (min-width:768px) and (orientation:portrait)

D - @media(min-width:1200px)

E - A and B both

F - All of the above

Answer : E

Explanation

E.This allows for devices with a maximum width of 768 pixels.This allows for devices with a maximum width of 478 pixels in portrait view, such as tablets.

Answer : E

Explanation

E.This installs all the necessary mobile packages.All mobile views and mobile master layout ensure that the page will load accordingly.

Answer : C

Explanation

C. Text revealed by mouse-overs not being picked up by search engine crawlers indicates that content is being skipped

Q 13 - You have been asked by the marketing department to help improve your company's ranking in search engine results. They are particularly concerned about a section of the site that is highly interactive, with extensive mouse-over color, background, and text changes. Without looking at the code, what is the most likely reason for ranking low in search engine results?

A - Unclosed HTML tags

B - Content hidden in JavaScript tags

C - Broken links

D - Excessive number of images

E - C and B both

F - All of the above

Answer : B

Explanation

B.Additional views must be created or ported to fit the smaller layout.

Q 14 - You have been asked by a company to evaluate its web application as a user. The company wants you to review the website from outside its network and identify areas that might be problematic. You have been asked to consider SEO and accessibility. Which tools would be helpful for your review? (Choose all that apply.)

A - IIS SEO Toolkit

B - Internet Explorer F12 tools

C - IIS Logging tab

D - Bing Webmaster Toolkit

E - C and A both

F - All of the above

Answer : B

Explanation

B.The Internet Explorer F12 tool enables you view HTML and CSS code, which can help you detect structural problems or errors that might affect acces- sibility or SEO.

Q 15 - Your company has joined an industry accessibility group and you are a member. As one of your responsibilities, you have been asked to estimate the time it would take to modify your corporate site for accessibility. What should you consider to properly estimate the required time? (Choose all that apply.)

A - The amount of text in the website

B - The level of current usage of HTML helpers in your views

C - The numbers of controllers in the application

D - The complexity of your data entry forms

E - B and D both

F - All of the above

Answer : E

Explanation

E.Because ASP.NET MVC 3 HTML helpers are not ARIA compliant, you need to write custom HTML helpers or use a different process to create HTML forms.Because many of the problems with accessibility are related to giving context to content, complex forms need a thorough review to ensure that labels and section context are provided for every element on the page.

Q 16 - You are globalizing an application and are compiling a list of items that need to be translated. Which items should be included on the list? (Choose all that apply.)

A - Images that are used as part of the menu structure

B - The company logo

C - Server error-logging messages

D - Button tooltips

E - A and D both

F - All of the above

Answer : E

Explanation

E. Images that are being used for menus likely have text displayed on them. That text should be localized, and extra sets of buttons might have to be created.Tooltips are supposed to give extra contextual help about the item the mouse hovers over. It is important to get them translated.

Q 17 - You are creating an ASP.NET MVC website and you want to replace a <h2>hello</h2>tag within the view with custom resources you have created. What should you use?

A - <h2>@mvcapp.Resources.Home.Index.Heading</h2>

B - <h2div="resource">Hello</h2>

C - <h2 class="resource">Hello</h2>

D - <h2>@mvcapp.Resources.Home.Index.HeadingHello</h2>

E - C and B both

F - All of the above

Answer : A

Explanation

A.This is the correct way to insert resources into a view

Answer : D

Explanation

D.Assembly Linker generates modules or resource files.

Answer : B

Explanation

B.It filters out those users not on an SSL connection before performing the more resource-intensive authentication check.

Answer : A

Explanation

A.The FileResult property was designed for this need.

Answer : D

Explanation

D.The key is separating your data input fields from the provided input fields. You can strongly-bind to yours because you have full control over the relationship between your model and your view, and can then use the ToValueProvider to merge the other model that is tied to the provided input fields.

Q 22 - You are developing an ASP.NET MVC application. You have a set of requirements to create a help section for remote users. Your typical help scheme is help/desktop or help/mobile, so logically this section should be help/remote. The change board wants the links in the application to point to the default support site. Which code segment would you use?

A - routes.MapRoute(name: "Default",url: "{controller}/{action}/{id}", defaults: new { controller = "Home",action = "Index", id = UrlParameter.Optional });

B - routes.MapRoute( "remote", "help/remote",new { controller = "support", action = "Index" });

C - routes.MapRoute( "remote", "help",new { controller = "support", action = "Index" });

D - routes.MapRoute( "remote", "remote/help",new { controller = "support", action = "Index" });

E - C and C both

F - All of the above

Answer : B

Explanation

B.This is how you add an additional route and point to a different controller.

Answer : B

Explanation

B.IgnoreRoute is the correct statement to use.

Answer : E

Explanation

E.Creating partial classes offers some relief to the problem that you are ex- periencing, although not as much as a more-functional separation such as offered by areas. You do not have to make any UI changes, however. Your best move is to separate the AJAX components into an area. You would have to change all the calls to it, but you would achieve complete separa- tion of concern for AJAX calls.

Answer Sheet

Question Number Answer Key
1 C
2 B
3 F
4 B
5 D
6 B
7 E
8 E
9 B
10 E
11 E
12 C
13 B
14 B
15 E
16 E
17 A
18 D
19 B
20 A
21 D
22 B
23 B
24 E
25 D
mvc_framework_questions_answers.htm
Advertisements