PrepAway - Latest Free Exam Questions & Answers

Author: seenagape

Which code segment should you insert at line 03?

You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4 to create an application. You are creating the data layer of the application. You write the following code segment. (Line numbers are included for reference only.)
01 public static SqlDataReader GetDataReader(string sql){
02 SqlDataReader dr;
03
04 return dr;
05 }
You need to ensure that the following requirements are met:
The SqlDataReader returned by the GetDataReader method can be used to retrieve rows from the database.
SQL connections opened within the GetDataReader method will close when the SqlDataReader is closed.
Which code segment should you insert at line 03?

Which code segment should you insert at line 06?

You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4 to create an application. The application connects to a Microsoft SQL Server database. The application has two DataTable objects that reference the Customers and Orders tables in the database. The application contains the following code segment. (Line numbers are included for reference only.)

01 Dim customerOrders As New DataSet()
02 customerOrders.EnforceConstraints = True
03 Dim ordersFK As New ForeignKeyConstraint(“ordersFK”,
04 customerOrders.Tables(“Customers”).Columns(“CustomerID”),
05 customerOrders.Tables(“Orders”).Columns(“CustomerID”))
06
07 customerOrders.Tables(“Orders”).Constraints.Add(ordersFK)

You need to ensure that an exception is thrown when you attempt to delete Customer records that have related Order records. Which code segment should you insert at line 06?

What should you do?

You create a new ASP.NET MVC 2 Web application.
The following default routes are created in the Global.asax.cs file. (Line numbers are included for reference only.)

01 public static void RegisterRoutes(RouteCollection routes)
02 {
03 routes.IgnoreRoute(“{resource}.axd/{*pathInfo}”);
05 routes.MapRoute(“Default”, “{controller}/{action}/{id}”, new {controller = “Home”, action = “Index”, id = “”});
06 }

You implement a controller named HomeController that includes methods with the following signatures.

public ActionResult Index()
public ActionResult Details(int id)
public ActionResult DetailsByUsername(string username)

You need to add a route to meet the following requirements.
* The details for a user must to be displayed when a user name is entered as the path by invoking the DetailsByUsername action.
* User names can contain alphanumeric characters and underscores, and can be between 3 and 20 characters long.

What should you do?

Which two approaches could you recommend?

You are designing an ASP.NET Web application that displays daily sales information. The sales information is stored in a large Microsoft SQL Server database. The database information is updated each night. During the day, people use the Web application to display a set of standard sales reports based on the latest database information.
The SQL queries that are required to retrieve the database information can take from 20 to 30 seconds to execute.
You need to design the application to ensure that pages usually load in no more than 5 seconds.
Which two approaches could you recommend? (Each correct answer presents a complete solution. Choose two.)

What should you do?

You are analyzing a Windows client application that uses Microsoft Visual Studio 2010 and Microsoft SQL Server 2008. The application updates two database tables from the main user interface (UI) thread. You need to ensure that the following requirements are met:
* The database tables are either updated simultaneously or not updated at all.
* Users are notified of the success or failure of the updates.
* Users are able to perform other tasks during the update process.
What should you do?

Which code segment should you insert at line 03?

You use Microsoft .NET Framework 4.0 to develop an application.
You write the following code to update data in a Microsoft SQL Server 2008 database.
(Line numbers are included for reference only.)

01 private void ExecuteUpdate(SqlCommand cmd, string connString, string updateStmt)
02 {
03 …
04 }

You need to ensure that the update statement executes and that the application avoids connection leaks.
Which code segment should you insert at line 03?

What should you do?

You create a new ASP.NET MVC 2 Web application.
The following default routes are created in the Global.asax.cs file. (Line numbers are included for reference only.)

01 public static void RegisterRoutes(RouteCollection routes)
02 {
03 routes.IgnoreRoute(“{resource}.axd/{*pathInfo}”);
05 routes.MapRoute(“Default”, “{controller}/{action}/{id}”, new {controller = “Home”, action = “Index”, id = “”});
06 }

You implement a controller named HomeController that includes methods with the following signatures.

public ActionResult About()
public ActionResult Index()
public ActionResult Details(int id)

You need to ensure that the About action is invoked when the root URL of the site is accessed.
What should you do?

What should you do?

You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4 to create an application. The application uses the ADO.NET Entity Framework to model entities. The application allows users to make changes while disconnected from the data store. Changes are submitted to the data store by using the SubmitChanges method of the DataContext object. You receive an exception when you call the SubmitChanges method to submit entities that a user has changed in offline mode. You need to ensure that entities changed in offline mode can be successfully updated in the data store. What should you do?

Which code segment should you use?

You use Microsoft .NET Framework 4 to create a Windows Forms application. You have a dataset as shown in the following exhibit. You plan to add a DataGridView to display the dataset. You need to ensure that the DataGridView meets the following requirements: Shows Order Details for the selected order. Shows only Order Details for items that have UnitPrice greater than 20. Sorts Products by ProductName Which code segment should you use?