PrepAway - Latest Free Exam Questions & Answers

Category: 70-521

Exam 70-521: Upgrade: Transition your MCPD .NET Framework 3.5 Windows Developer Skills to MCPD .NET 4 Windows Applications Developer

Which code segment should you insert at line 11?

You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4 to create an application. The application connects to a Microsoft SQL Server database. You write the following code segment that executes two commands against the database within a transaction. (Line numbers are included for reference only.)
01 Using connection As New SqlConnection(cnnStr)
02 connection.Open()
03 Dim sqlTran As SqlTransaction = connection.BeginTransaction()
04 Dim command As SqlCommand = connection.CreateCommand()
05 command.Transaction = sqlTran
06 Try
07 command.CommandText = “INSERT INTO Production.ScrapReason(Name) VALUES(‘Wrong size’)”
08 command.ExecuteNonQuery()
09 command.CommandText = “INSERT INTO Production.ScrapReason(Name) VALUES(‘Wrong color’)”
10 command.ExecuteNonQuery()
11
12 End Using

You need to log error information if the transaction fails to commit or roll back.
Which code segment should you insert at line 11?

What should you do?

You are designing a Windows Presentation Foundation (WPF) application by using Microsoft .NET Framework 4 and Microsoft Visual Studio 2010. The application will consist of a user interface (UI) tier and a middle tier. The middle tier will be implemented by using Windows Communication Foundation (WCF). You plan to design the exception handling strategy for the application. Each method in the middle tier will contain the following catch block. Catch e As ArgumentNullException

Throw e When testing the application, you discover that all ArgumentNullExceptions that occur in the middle tier do not contain accurate stack trace information. What should you do?

Which code segment should you insert at line 04?

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 uses the following object query to load a product from the database. (Line numbers are included for reference only.) 01 Using advWorksContext As New AdventureWorksEntities() 02 Dim productQuery As ObjectQuery(Of Product) = 03
advWorksContext.Product.Where(“it.ProductID = 900”) 04 05 End Using You need to log the command that the query executes against the data source. Which code segment should you insert at line 04?

Which code segment should you insert at line 03?

You use Microsoft .NET Framework 4 to create a Windows Forms application. You write the following code segment. (Line numbers are included for reference only.) 01 NotInheritable

Class FormSettings 02 Inherits ApplicationSettingsBase 03 04 Public Property Description() As [String] 05 Get 06 Return DirectCast(Me(“Description”), [String]) 07 End Get 08 Set 09 Me(“Description”) = value 10 End Set 11 End Property 12 End Class
You need to ensure that the first time each user opens the application, a text field displays the following message: “Please enter your setting.” Which code segment should you insert at line 03?

Which code segment should you use?

You use Microsoft .NET Framework 4 to create a Windows Forms client application. You write the following code segment. NotInheritable Class FormSettings Inherits ApplicationSettingsBase <UserScopedSetting> _ <DefaultSettingValue(“225, 200”)> _ Public Property FormSize() As Size Get Return DirectCast(Me(“FormSize”), Size) End Get Set Me(“FormSize”) = value End Set End Property End Class The application contains a form of type Form1 that contains a FormSettings object named frmSettings1. You need to maintain the user’s form size preference each time the user executes the application. Which code segment should you use?

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 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 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?


Page 9 of 13« First...7891011...Last »