Microsoft 70-511 Real Exam Questions
TS: Windows Applications Development with Microsoft .NET Framework 4
This exam is designed to test the candidate’s knowledge and skills for developing applications using Windows Forms, WPF and the .NET Framework 4.
Questions that contain code will be presented in either VB or C#. Candidates can select one of these languages when they start the exam.
QUESTION NO: 1
You use Microsoft .NET Framework 4 to create a Windows Presentation Foundation (WPF) application. You want to add an audio player that plays .wav or .mp3 files when the user clicks a button.
You plan to store the name of the file to a variable named SoundFilePath.
You need to ensure that when a user clicks the button, the file provided by SoundFilePath plays.
What should you do?
A. Write the following code segment in the button onclick event.
System.Media.SoundPlayer player = new System.Media.SoundPlayer(SoundFilePath); player.play();
B. Write the following code segment in the button onclick event. MediaPlayer player = new MediaPlayer();
player.Open(new URI(SoundFilePath), UriKind.Relative)); player.play();
C. Use the following code segment from the PlaySound() Win32 API function and call the PlaySound function in the button onclick event. [sysimport(dll="winmm.dll")]
public static extern long PlaySound(String SoundFilePath, long hModule, long dwFlags);
D. Reference the Microsoft.DirectX Dynamic Link Libraries. Use the following code segment in the button onclick event.
Audio song = new Song(SoundFilePath);
song.CurrentPosition = song.Duration; song.Play();
Answer: B
QUESTION NO: 2
You use Microsoft .NET Framework 4 to create a Windows Presentation Foundation (WPF) application.
You want to add an audio player that plays .wav or .mp3 files when the user clicks a button.
You plan to store the name of the file to a variable named SoundFilePath.
You need to ensure that when a user clicks the button, the file provided by SoundFilePath plays.
What should you do?
A. Write the following code segment in the button onclick event.
System.Media.SoundPlayer player = new System.Media.SoundPlayer(SoundFilePath); player.play();
B. Write the following code segment in the button onclick event. MediaPlayer player = new MediaPlayer();
player.Open(new URI(SoundFilePath), UriKind.Relative)); player.play();
C. Use the following code segment from the PlaySound() Win32 API function and call the PlaySound function in the button onclick event. [sysimport(dll="winmm.dll")] public static extern long PlaySound(String SoundFilePath, long hModule, long dwFlags);
D. Reference the Microsoft.DirectX Dynamic Link Libraries. Use the following code segment in the button onclick event.
Audio song = new Song(SoundFilePath);
song.CurrentPosition = song.Duration; song.Play();
Answer: B
QUESTION NO: 3
You use Microsoft .NET Framework 4 to create a Windows Presentation Foundation (WPF) application.
You write the following code fragment.
<StackPanel>
<StackPanel.Resources>
<Style TargetType="{x:Type Button}">
<EventSetter Event="Click" Handler="ButtonHandler"/>
</Style>
</StackPanel.Resources>
<Button Name="OkButton">Ok</Button>
<Button Name="CancelButton" Click="CancelClicked">Cancel</Button>
</StackPanel>
You need to ensure that the ButtonHandler method is not executed when the user clicks the CancelButton button.
Which code segment should you add to the code-behind file
A. private void CancelClicked(object sender, RoutedEventArgs e)
{
Button btn = (Button)sender;
btn.Command = null;
}
B. private void CancelClicked(object sender, RoutedEventArgs e) {
Button btn = (Button)sender;
btn.IsCancel = true;
}
C. private void CancelClicked(object sender, RoutedEventArgs e) {
e.Handled = true;
}
D. private void CancelClicked(object sender, RoutedEventArgs e) { e.Handled = false;
}
Answer: C
QUESTION NO: 4
You use Microsoft .NET Framework 4 to create a Windows Presentation Foundation (WPF) application.
You write the following code fragment.
<StackPanel>
<StackPanel.Resources>
<Style TargetType="{x:Type Button}">
<EventSetter Event="Click" Handler="ButtonHandler"/>
</Style>
</StackPanel.Resources>
<Button Name="OkButton">Ok</Button>
<Button Name="CancelButton" Click="CancelClicked">Cancel</Button>
</StackPanel>
You need to ensure that the ButtonHandler method is not executed when the user clicks the CancelButton button.
Which code segment should you add to the code-behind file
A. Private Sub CancelClicked(sender As Object, e As RoutedEventArgs)
Dim btn As Button = DirectCast(sender, Button)
btn.Command = Nothing
End Sub
B. Private Sub CancelClicked(sender As Object, e As RoutedEventArgs) Dim btn As Button = DirectCast(sender, Button)
btn.IsCancel = True
End Sub
C. Private Sub CancelClicked(sender As Object, e As RoutedEventArgs) e.Handled = True End Sub
D. Private Sub CancelClicked(sender As Object, e As RoutedEventArgs) e.Handled = False End Sub
Answer: C
QUESTION NO: 5
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 CollectionView Data { get; set; }
} public class BusinessObject
{
public string Name { get; set; }
} 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
A. {Binding Path=Data/Name, FallbackValue=’N/A’ }
B. {Binding Path=Data.Name, FallbackValue=’N/A’ }
C. {Binding Path=Data/Name, TargetNullValue=’N/A’ }
D. {Binding Path=Data.Name, TargetNullValue=’N/A’ }
Answer: A
QUESTION NO: 6
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 CollectionView Data { get; set; }
} public class BusinessObject
{
public string Name { get; set; }
} 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
A. {Binding Path=Data/Name, FallbackValue=’N/A’ }
B. {Binding Path=Data.Name, FallbackValue=’N/A’ }
C. {Binding Path=Data/Name, TargetNullValue=’N/A’ }
D. {Binding Path=Data.Name, TargetNullValue=’N/A’ }
Answer: A
Download | Password: certificatexam.com