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 two actions should you perform?

You use Microsoft .NET Framework 4 to create a Windows Presentation Foundation (WPF) application. You write the following code segment. (Line numbers are included for reference only.) 01 Public Class Contact 02 Private _contactName As String 03 04 Public Property ContactName() As String 05 Get 06 Return _contactName 07 End Get 08 Set 09 _contactName = value 10 End Set 11 End Property 12 13 End Class You add the following code fragment within a WPF window control. <TextBox> <TextBox.Text> <Binding Path=”ContactName” UpdateSourceTrigger=”PropertyChanged”> <Binding.ValidationRules> <DataErrorValidationRule /> </Binding.ValidationRules> </Binding> </TextBox.Text> </TextBox>

The TextBox control is databound to an instance of the Contact class. You need to ensure that the Contact class contains a business rule to ensure that the ContactName property is not empty or NULL. You also need to ensure that the TextBox control validates the input data. Which two actions should you perform? (Each correct answer presents part of the solution.
Choose two).

Which two actions should you perform?

You use Microsoft .NET Framework 4 to create a Windows Forms application. You add a new class named Customer to the application. You select the Customer class to create a new object data source. You add the following components to a Windows Form: A BindingSource component named customerBindingSource that is databound to the Customer object data source. A set of TextBox controls to display and edit the Customer object properties. Each TextBox control is databound to a property of the customerBindingSource component. A n ErrorProvider component named errorProvider that validates the input values for each TextBox control. You need to ensure that the input data for each TextBox control is automatically validated by using the ErrorProvider component.
Which two actions should you perform? (Each correct answer presents part of the solution. Choose two.)

Which code segment should you insert at line 02?

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 create the classes shown in the following exhibit. You add the following code segment to the application. (Line numbers are included for reference only.)

01 Public Sub QueryPlayers(leagues As List(Of League))
02
03 End Sub

You create a LINQ query to retrieve a collection of Player objects. You need to ensure that the collection includes all the players from each team and every league. Which code segment should you insert at line 02?

What are two possible ways to achieve this goal?

You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4 to create an application. The application connects to a Microsoft SQL Server 2008 database. You create classes by using LINQ to SQL based on the records shown in the exhibit. (Click the Exhibit button.) You need to create a LINQ query to retrieve a list of objects that contains the OrderID and CustomerID properties. You need to retrieve the total price amount of each Order record. What are two possible ways to achieve this goal? (Each correct answer presents a complete solution. Choose two.)

Which binding expression should you use?

You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4 to create a Windows Presentation Foundation (WPF) application. You create a WPF window in the application. You add the following code segment to the application.

Public Class ViewModel
Public Property Data() As CollectionView Get End Get Set End Set End Property End Class Public Class BusinessObject Public Property Name() As String Get End Get Set End Set End Property End Class The DataContext property of the window is set to an instance of the ViewModel class. The Data property of the ViewModel instance is initialized with a collection of BusinessObject objects. You add a TextBox control to the window. You need to bind the Text property of the TextBox control to the Name property of the current item of the CollectionView of the DataContext object. You also need to ensure that when a binding error occurs, the Text property of the TextBox control is set to N/A . Which binding expression should you use?

Which code segment should you insert at line 09?

You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4 to create an application. The application connects to a Microsoft SQL Server 2008 database. The database includes a database table named ProductCatalog as shown in the exhibit. (Click the Exhibit button.) You add the following code segment to query the first row of the ProductCatalog table. (Line numbers are included for reference only.)
01 Using cnx As var = New SqlConnection(connString)
02 Dim command As var = cnx.CreateCommand()
03 command.CommandType = CommandType.Text
04 command.CommandText = “SELECT TOP 1 * FROM dbo.ProductCatalog”
05 cnx.Open()
06 Dim reader As var = command.ExecuteReader()
07 If reader.Read() Then
08 Dim id As var = reader.GetInt32(0)
09
10 reader.Close()
11 End If
12 End Using

You need to read the values for the Weight, Price, and Status columns. Which code segment should you insert at line 09?

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 2008 database. The database includes a table named dbo.Documents that contains a column with large binary data. You are creating the Data Access Layer (DAL). You add the following code segment to query the dbo.Documents table. (Line numbers are included for reference only.)

01 Public Sub LoadDocuments(cnx As DbConnection)
02 Dim cmd As var = cnx.CreateCommand()
03 cmd.CommandText = “SELECT * FROM dbo.Documents”
04 …
05 cnx.Open()
06
07 ReadDocument(reader)
08 End Sub

You need to ensure that data can be read as a stream.
Which code segment should you insert at line 06?

What should you do?

You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4 to create an application. The application contains the following code segment. (Line numbers are included for reference only.)

01 Class DataAccessLayer
02 Private Shared connString As String
03 04 …
05 Public Shared Function GetDataTable(command As String) As DataTable
06 07 …
08 End Function
09 End Class

You need to define the connection life cycle of the DataAccessLayer class. You also need to ensure that the application uses the minimum number of connections to the database. What should you do?

What should you do?

You use Microsoft .NET Framework to create a Windows Presentation Foundation (WPF) application. You create a window that contains a Button control and a MenuItem control. Both controls are labeled “Add sugar.” The Command properties of the Button and MenuItem controls are set to the same RoutedCommand named AddSugarCommand. You write the following code segment.

Private Sub CanAddSugar(sender As Object, e As CanExecuteRoutedEventArgs) …
End Sub

You need to ensure that when the CanAddSugar method sets e.CanExecute to false, the MenuItem and Button controls are disabled. What should you do?

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 Shared Function GetDataReader(sql As String) As SqlDataReader
02 Dim dr As SqlDataReader = Nothing
03
04 Return dr
05 End Function

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?


Page 10 of 13« First...89101112...Last »