MVC Framework Online Quiz


Advertisements


Following quiz provides Multiple Choice Questions (MCQs) related to MVC Framework. You will have to read all the given answers and click over the correct answer. If you are not sure about the answer then you can check the answer using Show Answer button. You can use Next Quiz button to check new set of questions in the quiz.

Questions and Answers

Q 1 - You are developing an application. One requirement is that part of your data access layer needs to be available to a third party, that wants to get this information from a REST URL in XML. Your company does not have experience with web services, but you have several websites running ASP.NET MVC 4. How could you design and provide these new services? (Choose all that apply.)

A - Task an individual on staff to learn WCF, and have this individual develops and deploys these new services using WCF.

B - Use the Web API to create REST services using ApiController in which the serialization type is defined by the Accepts property of the browser.

C - Build a basic ASP.NET MVC 4 project in which the view simply passes through the information provided by the controller, and the controller manages the code for serializing the response.

D - Create an ASP.NET ASMX services file to get, serialize, and return the data.

E - B,C and D

F - All of the above

Answer : E

Explanation

E.Using ASP.NET MVC is another way to create a controller that will return XML.

Answer : E

Explanation

E.Your application needs to manage whatever information might be re- quired to access the state management system.Your application needs to manage the passing of the identifier between requests.

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, 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.

Q 5 - 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 : E

Explanation

E.Creating a globally applied action filter enables you to save the state of every action taken by the user while logged in to your site.By creating a globally applied action filter you have ensured that every action taken by the user will be logged.

Q 7 - You want to configure Windows Azure diagnostics. Where do you configure the specific Performance Monitors you want to have run in support of your application?

A - ServiceDefinition.csdef

B - ServiceConfiguration.cscfg

C - Diagnostics.wadcfg

D - Web.config

E - A and B both

F - All of the above

Answer : C

Explanation

C.You configure specific monitors that will run in your application in the Diagnostics.wadcfg file.

Q 8 - What attribute or code snippet within a controller enables a role named Admin to access actions or code blocks after the check-in code?

A - RoleProvider.GetRolesForUser("Admin")

B - [Authorize(Roles="Admin")]

C - RoleProvider.IsUserInRole(User.Name)

D - [AuthorizeAttribute(Roles="Admin")]

E - A and B both

F - All of the above

Answer : B

Explanation

B.The Authorize attribute handles authorization on a controller and/or action basis by using the Roles= qualifier

Q 9 - You are writing an action method called AddProduct inside the Product controller. The logic in your code indicates that you need to call the Cart controller's Add method as a result of your controller's action method. Which line of code would accomplish this?

A - return Content("Cart.Add")

B - Response.Redirect("Cart.aspx?Add")

C - return redirect("Cart/Add")

D - return View("Cart.Add")

E - A and D both

F - All of the above

Answer : C

Explanation

C.This will redirect to the Add method of Cart controller

Q 10 - Which Helper Method is used to return a user-defined content type.

A - Content

B - JavaScript

C - View

D - RedirectToRoute

E - A and D both

F - All of the above

Answer : A

Explanation

A.Content Helper Method is used to return a user-defined content type.


mvc_framework_questions_answers.htm

Advertisements