Learn About Windows Forms Application Development

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);

C.    Replace line 03 with the following code: throw new InstallException("The M drive is in use.");

D.    Replace line 03 with the following code: InstallException ex = new InstallException(); throw new ApplicationException("The M drive is in use.", ex);

Answer:
C

Tutorial:
You should throw an instance of InstallException. This passes information to the Microsoft Windows Installer and causes the installation to be rolled back.

You should not call the Commit method after you throw the exception. When an exception is thrown, execution is propagated up the call stack until the exception is handled. This means the Commit method will never get called when the exception is thrown.

You should not call the Rollback method after you throw the exception. When an exception is thrown, execution is propagated up the call stack until the exception is handled. This means that the Rollback method will never get called when the exception is thrown.

You should not throw an instance of ApplicationException. This solution will not cause the installation to be rolled back.

Reference:
Error Handling in Custom Actions
MSDN
http://msdn.microsoft.com/en-us/library/xc8bz3y5.aspx

Objective: Enhance usability.
Sub-objective: Perform drag-and-drop operations.

Single answer, multiple-choice

You are developing a Microsoft Windows Forms application that allows electrical engineers to design circuit boards. You create a custom control that represents the design surface. A TreeView control contains nodes that represent electronic components. Users are able to drag components from the TreeView control to the design surface.

You need to handle an event so you can highlight the available areas on the design surface where a component can be dropped. Which event should you handle?

A.    GiveFeedback
B.    DragEnter
C.    QueryContinueDrag
D.    DragOver

Answer:
D

Tutorial:
You should handle the DragOver event. This event is raised as the mouse cursor moves over a control during a drag-and-drop operation.

You should not handle the GiveFeedback event. This event is raised when a drag-and-drop operation is started and when the keyboard or mouse button state changes. For example, if a drag-and-drop operation is in progress with the mouse button pressed, the GiveFeedback event gets raised when you release the mouse button.

You should not handle the DragEnter event. This event is raised only when the mouse cursor enters a control during a drag-and-drop operation.

You should not handle the QueryContinueDrag event. This event is raised when the keyboard or mouse button state changes. For example, if a drag-and-drop operation is in progress with the mouse button pressed, the QueryContinueDrag event gets raised when you release the mouse button.

Reference:
Walkthrough: Performing a Drag-and-Drop Operation in Windows Forms
MSDN
http://msdn.microsoft.com/en-us/library/za0zx9y0.aspx

Objective: Configure and deploy applications.
Sub-objective: Install a Windows Presentation Foundation (WPF) browser application by using ClickOnce.

Single answer, multiple-choice

You are planning to deploy a Windows Presentation Foundation (WPF) application. A different version should be deployed on a computer with a 64-bit processor than on a computer with a 32-bit processor. Users must be able to install the application by clicking a link in a browser. The application must support automatic update. You need to create the necessary deployment files. What should you do?

A.    For each processor type, create a ClickOnce deployment and set the processorArchitecture attribute of the assemblyIdentity element in the application manifest.
B.    Create a ClickOnce deployment with two deployment manifests. Set the processorArchitecture attribute of the assemblyIdentity element in each deployment manifest.
C.    For each processor type, create a Windows Installer file and add a link to the Web page.
D.    Create a single Windows Installer file.

Answer:
A

Tutorial:
For each processor type, you should create a ClickOnce deployment and set the processorArchitecture attribute of the assemblyIdentity element in the application manifest. A ClickOnce deployment can be installed through a link on a Web page. The deployment is driven by a deployment manifest and an application manifest.

The application manifest is an XML file that describes the application itself and defines dependency information for the application, including the operating system version, processor architecture and language. The assemblyIdentity element allows you to identify dependencies for the installation, including the processor architecture. ClickOnce will examine the system where application is being installed to ensure the dependencies defined in application manifest are met.

You should not create a ClickOnce deployment with two deployment manifests and set the processorArchitecture attribute of the assemblyIdentity element in each deployment manifest. Each ClickOnce deployment has one deployment manifest and one application manifest. Also, dependency information is set in the application manifest.

You should not create a Windows Installer file and add a link for each processor type. A Windows Installer file does not support automatic update. Also, users might attempt to install the wrong version of the application because not all users know whether their processor is 32-bit or 64-bit.

You should not create a single Windows Installer file. A Windows Installer file does not support automatic update.

References:
Element (ClickOnce Application)
MSDN
http://msdn.microsoft.com/en-us/library/cs1kkt20.aspx

Application Deployment Prerequisites
MSDN
http://msdn.microsoft.com/en-us/library/h4k032e1.aspx

Like what you see? Share it.Share on Google+Share on LinkedInShare on FacebookShare on RedditTweet about this on TwitterEmail this to someone
cmadmin

ABOUT THE AUTHOR

Posted in Archive|

Comment:

Leave a comment

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>