Learn About Windows Forms Application Development
By Certification Magazine —
1 | 2 |These practice test questions from MeasureUp are based on the C# version of Microsoft’s exam 70-505: Microsoft .NET Framework 3.5 – Windows Forms Application Development .
The audience for this exam includes individuals who are responsible for developing Windows-based software applications. Experience using Visual Studio 2008 and .NET Framework 3.5 and in developing and deploying Windows-based applications will help you prepare for this exam.
Candidates who pass exam 70-505 earn credit toward three certifications:
• MCTS: .NET Framework 3.5, Windows Forms Applications
• MCPD: Windows Developer 3.5
• MCPD: Enterprise Application Developer 3.5
MeasureUp offers practice tests for both the C# version and the VB version of exam
70-505.
Objective: Integrate data in a Windows forms application.
Sub-objective: Implement data-bound controls.
Single answer, multiple-choice
You call a stored procedure that returns a row set containing data about parts for electronic devices. You load the part data into a DataSet instance named dataSet, which contains a single DataTable instance. The TableName property of the DataTable instance is set to Part.
You need to display the part data in a DataGridView control named dataGridView. Which code segment should you use?
A. dataGridView.DataSource = dataSet; dataGridView.DataMember = "Part";
B. dataGridView.DataSource = dataSet.Tables["Part"]; dataGridView.DataMember = "DataTable";
C. dataGridView.DataSource = dataSet.Tables[0]; dataGridView.DataMember = "Part";
D. dataGridView.DataSource = dataSet; dataGridView.DataMember = "TableName.Part";
Answer:
A
Tutorial:
You should set the DataGridView control's DataSource property to the DataSet instance and the DataMember property to Part. When you bind a DataGridView control to a DataSet instance, the DataMember property specifies the table from which to obtain the data.
You should not set the DataMember property if you set the DataSource property to the DataTable instance that represents the Part data. You should set the DataMember property only if the data source contains multiple child data sources.
You should not set the DataMember property to TableName.Part. When you bind a DataGridView control to a DataSet instance, the DataMember property specifies the name of the table from which it should obtain the data. In this scenario, the table name is Part.
Reference:
DataGridView Control Overview (Windows Forms), MSDN,
http://msdn.microsoft.com/en-us/library/k39d6s23.aspx
Objective: Implement asynchronous programming techniques to improve the user experience.
Sub-objective: Implement an asynchronous method.
Multiple answer, multiple-choice
You obtain an instance of a Queue class named jobs that represents a queue of long-running jobs. The Job class is defined as follows:
public class Job
{
public void Download()
{
}
}
You need to call the Download method for each Job instance in the jobs queue on a separate thread. Which code segment should you use? (Each correct answer presents a complete solution. Choose two.)
A. ThreadStart threadStart = delegate { foreach (Job job in jobs) { job.Download(); } }; Thread thread = new Thread(threadStart); thread.Start(jobs);
B. ParameterizedThreadStart threadStart = delegate(object args) { Queue jobQueue = (Queue) args; foreach (Job job in jobQueue) { job.Download(); } }; Thread thread = new Thread(threadStart); thread.Start();
C. ParameterizedThreadStart threadStart = delegate(object args) { Queue jobQueue = (Queue) args; foreach (Job job in jobQueue) { job.Download(); } }; Thread thread = new Thread(threadStart); thread.Start(jobs);
D. ThreadStart threadStart = delegate { foreach (Job job in jobs) { job.Download(); } }; Thread thread = new Thread(threadStart); thread.Start();
E. ParameterizedThreadStart threadStart = delegate(object args) { foreach (Job job in jobs) { job.Download(); } }; Thread thread = new Thread(threadStart); thread.Start();
Answers:
C, D
Tutorial:
You should use the ParameterizedThreadStart delegate to invoke a method that accepts parameters on a separate thread. The ParameterizedThreadStart delegate accepts a single Object instance as a parameter that specifies the argument to the method. The Thread class is overloaded to accept either a ThreadStart delegate instance or a ParameterizedThreadStart delegate instance.
If you use the ThreadStart delegate, you must call the Thread.Start overload that takes no parameters. If you use the ParameterizedThreadStart delegate, you must call the Thread.Start overload that accepts an Object instance as a parameter.
The value of this parameter will be passed to the method that should be invoked in the new thread. In this scenario, you can pass the jobs instance as a parameter to the Thread.Start method. You can access the same jobs instance from the method that is associated with the ParameterizedThreadStart delegate.
With C#, you also can use anonymous methods. The benefit of anonymous methods is they allow you to use local variables in the context where the anonymous methods are defined. If you use an anonymous method, you can use the ThreadStart delegate and the Thread.Start method that accepts no parameters. The reason is because the jobs instance that you would typically pass to the Thread.Start method already is available to the anonymous method.
You should not call the Thread.Start method that accepts a parameter if you use the ThreadStart delegate. Otherwise, an exception will be thrown at run time because the parameterized Thread.Start method accepts a ParameterizedThreadStart delegate instance.
You should not call the Thread.Start method that accepts no parameters if you use the ParameterizedThreadStart delegate. Otherwise, an exception will be thrown at run time because the zero-parameter Thread.Start method accepts a ThreadStart delegate instance.
Reference:
Thread.Start Method (Object)
MSDN
http://msdn.microsoft.com/en-us/library/6x4c42hc.aspx
Objective: Configure and Deploy applications.
Sub-objective: Create a Windows Forms setup application.
Single answer, multiple-choice
You override the Install method of an Installer-derived class and add the following code (line numbers are included for reference only):
01 if (driveInUse)
02 {
03 throw new ApplicationException("The M drive is in use.");
04 }
The driveInUse variable is a Boolean variable that indicates whether the M drive is in use. You expect installation to be rolled back if the variable is set to true. However, this does not happen.
You need to modify the code to allow the Microsoft Windows Installer to automatically roll back the installation when the variable returns true. What should you do?
A. Add the following code between lines 03 and 04: Commit(null);
B. Add the following code between lines 03 and 04: Rollback(null);
1 | 2 |



