- MVC Framework Tutorial
- MVC Framework - Home
- MVC Framework - Introduction
- MVC Framework - Architecture
- MVC Framework - ASP.NET Forms
- MVC Framework - First Application
- MVC Framework - Folders
- MVC Framework - Models
- MVC Framework - Controllers
- MVC Framework - Views
- MVC Framework - Layouts
- MVC Framework - Routing Engine
- MVC Framework - Action Filters
- Advanced Example
- MVC Framework - Ajax Support
- MVC Framework - Bundling
- Exception Handling
- MVC Framework Useful Resources
- Questions & Answers
- MVC Framework - Quick Guide
- MVC Framework - Resources
- MVC Framework - Discussion
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.
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)
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?
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.
Q 3 - In which of the following scenarios should you include validation? (Choose all that apply.)
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")
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?
B - @Html.EditorFor(model → model.PhoneNumber)
D - PhoneNumber: @Html.TextBox("phoneNumber", Request["phoneNumber"], new { size = 10 })
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";
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.)
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.
Q 8 - What are common methods for detecting the type of browser running on a client? (Choose all that apply.)
A - Use JavaScript to query for the userAgent header.
B - Use the window.addEventListener method.
C - Use the viewport <meta> tag.
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.
Q 9 - You are creating a different view for each of several different browsers/devices, such as Home.iemobile.cshtml and Home.IPad.cshtml. What is the best way to implement it so your application knows to look for the specific views?
A - Use the viewport <meta> tag.
B - Add a new DisplayModeProvider for each of the special view types you want to support.
C - Put logic into each action to select the appropriate view based on information in 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.)
B - @media (max-width:478px) and (orientation:portrait)
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.
Q 11 - You are modifying an existing ASP.NET MVC web application to incorporate mobile access. What should you do to ensure that mobile devices view mobile-only pages? (Choose all that apply.)
A - Run the Install-Package jQuery.Mobile.MVC command using the Package Manager console.
B - Create a _Layout.Mobile.cshtml master layout page.
C - Create additional views with .Mobile, such as Index.Mobile.cshtml.
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.
Q 12 - You are modifying an ASP.NET MVC web application for a client. The client requires that the application must be viewable on Android devices in a UI format native to the device. What should you do? (Choose all that apply.)
A - Run the Install-Package jQuery.Mobile.MVC command using the Package Manager console.
B - Create a viewport and use @media queries to make styles that are specific for Android.
C - Create corresponding mobile views for the project targeted toward Android.
D - Modify the Web.config file in Shared views in the project to add in support for other browsers.
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?
B - Content hidden in JavaScript tags
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.)
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
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
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>
Answer : A
Explanation
A.This is the correct way to insert resources into a view
Q 18 - You are developing an ASP.NET MVC application and you need to create satellite assemblies from resource files. What code should you use?
A - mage.exe /n: /embed:strings.de-DE.resources MyApp.de-DE.resources.dll
B - WinRes.exe /t: embed:strings.de-DE.resources /culture:de-DE
C - Lc.exestrings.de-DE.resourcesMyApp.de-DE.resources.dll
D - al.exe /t:lib /embed:strings.de-DE.resources /culture:de-DE /out:MyApp.de-DE. resources.dll
Answer : D
Explanation
D.Assembly Linker generates modules or resource files.
Q 19 - You have a set of requirements that expects a particular action to be accessed only through HTTPS by an authenticated user. What is the best way to meet these requirements?
A - Use the Authorize attribute before the RequireHttps filter.
B - Use the RequireHttps attribute before the Authorize filter.
Answer : B
Explanation
B.It filters out those users not on an SSL connection before performing the more resource-intensive authentication check.
Q 20 - You have written a shareware application and want to sell it on your personal website. You are considering various approaches for distributing the application after users purchase it. Which of the following is the best approach?
A - Use the FileResult action result to initiate the file download.
D - Create an email containing a link to a route from which the user can download the file.
Answer : A
Explanation
A.The FileResult property was designed for this need.
Q 21 - You have been tasked with modernizing an application created in ASP 3.0. Part of one of the pages contains HTML that comes as a string from a third-party application as part of a service call that populates part of a form. The same form contains input values for your application. You need to support the same business process as the original application, but you also want to use some MVC features. What is the approach?
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?
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" });
Answer : B
Explanation
B.This is how you add an additional route and point to a different controller.
Q 23 - You are developing an ASP.NET MVC application. You noticed a bug on the DVD controller of the application. You want to ignore the DVD pages until the bug is fixed. What should you do?
A - Add route.SetItem(route.Count, "dvd/"); to the RegisterRoute method.
B - Add route.IgnoreRoute("dvd/"); to the RegisterRoute method.
C - Add route.Insert(route.Count,"dvd/"); to the RegisterRoute method.
Answer : B
Explanation
B.IgnoreRoute is the correct statement to use.
Q 24 - You are the lead developer on a team that has been working on a large website for months, and several controllers are getting unwieldy. You do not have that problem with views and models because most of your communications are through AJAX to display snippets of information on the UI. What changes can best help you solve your problem? (Choose all that apply.)
B - Create an area called AJAX. Move all controllers, models, and views into the area.
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.
Q 25 - Your application manages the sale of expensive well-drilling equipment. Your IT director wants you to add functionality that sends an email to a customer's sales account manager whenever someone from your client company logs in to the system. What is an appropriate solution?
Answer : D
Explanation
D.This is be applied only because the user is leaving the login section of the application, at which point you also know whether they have been authenticated
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 |
To Continue Learning Please Login
Login with Google