Exam :070-316
Title:Developing Windows-based Applications with Visual C# .Net
Version Number:6.0
Fast Way to get your Certification
Real Level Practice Questions Guides www.correctexams.com Important Note:
Please Read Carefully
This Study Guide has been carefully written and compiled by correctexams experts. It is designed to help you learn the concepts behind the questions rather than be a strict memorization tool. Repeated readings will increase your comprehension.
We continually add to and update our Study Guides with new questions, so check that you have the latest version of this Guide right before you take your exam.
For security purposes, each PDF file is encrypted with a unique serial number associated …show more content…
with your correct
Exams account information. In accordance with International Copyright Law, correctexams reserves the right to take legal action against you should we find copies of this PDF file has been distributed to other parties.
Please tell us what you think of this Study Guide. We appreciate both positive and critical comments as your feedback helps us improve future versions.
We thank you for buying our Study Guides and look forward to supplying you with all your Certification training needs.
Good studying! correctexams Technical and Support Team
www.correctexams.com
Fast Way to get your Certification
Note: The book “MCAD/MCSD Self-Paced Training Kit: Developing Windows-Based Applications with
Microsoft Visual Basic .NET and Microsoft Visual C# .NET” from Microsoft Press is denoted as “70306/70-316 Training kit” in references.
Visual Studio .NET online references are also used.
QUESTION NO: 1
You use Visual Studio .NET to create a component named Request. This component includes a method named AcceptTKRequest, which tries to process new user requests for services.
AcceptTKRequest calls a private function named Validate.
You must ensure that any exceptions encountered by Validate are bubbled up to the parent form of
Request. The parent form will then be responsible for handling the exceptions. You want to accomplish this goal by writing the minimum amount of code.
What should you do?
A. Use the following code segment in AcceptTKRequest: this.Validate(); B. Use the following code segment in AcceptTKRequest: try { this.Validate(); } catch(Exception ex) { throw ex;
}
C. Use the following code segment in AcceptTKRequest: try { this.Validate(); } catch(Exception ex) { throw new Exception(“Exception in AcceptTKRequest”, ex);
}
D. Create a custom Exception class named RequestException by using the following code segment: public class RequestException:ApplicationException { public RequestException():base() {
}
public RequestException
(string message):base(message) {
}
public RequestException(string message,
Exception inner):base(message, inner) {
}
}
In addition, use the following code segment in AcceptTKRequest: try {
www.correctexams.com
-3-
Fast Way to get your Certification this.Validate(); } catch(Exception ex) { throw new RequestException(“Exception in AcceptTKRequest”, ex);
}
Answer: B
Explanation: The throw keyword is used to rethrow exceptions. We should catch the exceptions with a try…catch construct. We then simply rethrow the exception with the throw keyword.
Reference: 70-306/70-316 Training kit, Rethrowing Exceptions, Pages 239-240
Incorrect Answers
A: We must use a try…catch construction to be able to catch the exception.
C: There is no requirement to wrap the exception into a new exception with the new
Exception(“Exception in AcceptRequest”, ex) code. At the contrary, the scenario has the requirement only to bubble up the exceptions.
D: There is no need to create a custom exception.
QUESTION NO: 2
You work as software developer at TestKing inc. You need to develop a Windows form that provides online help for users. You want the help functionality to be available when users press the F1 key.
Help text will be displayed in a pop-up window for the text box that has focus.
To implement this functionality, you need to call a method of the HelpProvider control and pass the text box and the help text.
What should you do?
A.
B.
C.
D.
SetShowHelp
SetHelpString
SetHelpKeyword
ToString
Answer: B
Explanation: To associate a specific Help string with another control, use the SetHelpString method. The string that you associate with a control using this method is displayed in a pop-up window when the user presses the F1 key while the control has focus.
Reference: Visual Basic and Visual C# Concepts, Introduction to the Windows Forms HelpProvider
Component
www.correctexams.com
-4-
Fast Way to get your Certification
QUESTION NO: 3
You develop a Windows-based application that enables to enter product sales. You add a subroutine named TestKing.
You discover that TestKing sometimes raises an IOException during execution. To address this problem you create two additional subroutines named LogError and CleanUp. These subroutines are governed by the following rules:
•
•
LogError must be called only when TestKing raises an exception.
CleanUp must be called whenever TestKing is complete.
You must ensure that your application adheres to these rules. Which code segment should you use?
A. try {
TestKing();
LogError();
}
catch (Exception
CleanUp(e);
}
B. try {
TestKing();
} catch (Exception
LogError(e);
CleanUp();
}
C. try {
TestKing();
} catch (Exception
LogError(e);
} finally {
CleanUp();
}
D. try {
TestKing();
} catch (Exception
CleanUp(e);
} finally {
LogError();
}
e) {
e) {
e) {
e) {
Answer: C
www.correctexams.com
-5-
Fast Way to get your Certification
Explanation: We must use a try…catch…finally construct. First we run the TestKing() code in the try block. Then we use the LogError() subroutine in the catch statement since all exceptions are handled here.
Lastly we put the CleanUp() subroutine in the finally statement since this code will be executed regardless of whether an exception is thrown or not.
Reference: 70-306/70-316 Training kit, Page 237.
Incorrect Answers
A: LogError should not run each time, only when an exception occurs. It should be placed in the catch block, not in the try block.
B: CleanUp should not run only when an exception occurs. It should run when no exception occurs as well.
It should be put in the finally block not in the catch block.
D: CleanUp must be put in the finally block, and LogError in the catch block. Not the opposite way around.
QUESTION NO: 4
You use Visual Studio .NET to create a Windows-based application. The application includes a form named TestKForm, which displays statistical date in graph format. You use a custom graphing control that does not support resizing.
You must ensure that users cannot resize, minimize, or maximize TestKForm. Which three actions should you take? (Each answer presents part of the solution. Choose three)
A.
B.
C.
D.
E.
F.
G.
Set TestKForm.MinimizeBox to False.
Set TestKForm.MaximizeBox to False.
Set TestKForm.ControlBox to False.
Set TestKForm.ImeMode to Disabled.
Set TestKForm.WindowState to Maximized.
Set TestKForm.FormBorderStyle to one of the Fixed Styles.
Set TestKForm.GridSize to the appropriate size.
Answer: A, B, F
Explanation: We disable the Minimize and Maximize buttons with the TestKForm.Minimizebox and the
TestKForm.Maximizebox properties. Furthermore we should use a fixed FormBorderStyle to prevent the users from manually resizing the form.
Reference:
Visual Basic and Visual C# Concepts, Changing the Borders of Windows Forms
.NET Framework Class Library, Form.MinimizeBox Property [C#]
.NET Framework Class Library, Form.MaximizeBox Property [C#]
QUESTION NO: 5
www.correctexams.com
-6-
Fast Way to get your Certification
You develop an application that includes a Contact Class. The contact class is defined by the following code: public class Contact{ private string name; public event EventHandler ContactSaved; public string Name { get {return name;} set {name = value;}
}
public void Save () {
// Insert Save code.
// Now raise the event.
OnSave();
}
}
public virtual void OnSave() {
// Raise the event: if (ContactSaved != null) {
ContactSaved(this, null);
}
}
You create a form named TestKingForm. This form must include code to handle the ContactSaved event raised by the Contact object. The Contact object will be initialized by a procedure named
CreateContact.
Which code segment should you use?
A. private void HandleContactSaved() {
// Insert event handling code.
}
private void CreateContact() {
Contact oContact = new Contact(); oContact.ContactSaved += new EventHandler(HandleContactSaved); oContact.Name = “TestKing”; oContact.Save(); }
B. private void HandleContactSaved( object sender, EventArgs e) {
// Insert event handling code.
}
www.correctexams.com
-7-
Fast Way to get your Certification private void CreateContact() {
Contact oContact = new Contact(); oContact.Name = “TestKing”; oContact.Save(); }
C. private void HandleContactSaved( object sender, EventArgs e) {
// Insert event handling code.
}
private void CreateContact() {
Contact oContact = new Contact(); oContact.ContactSaved += new EventHandler (HandleContactSaved); oContact.Name = “TestKing”; oContact.Save(); }
D. private void HandleContactSaved(Object sender, EventArgs e) {
// Insert event-handling code.
}
private void CreateContact() {
Contact oContact = new Contact(); new EventHandler(HandleContactSaved); oContact.Name = “TestKing”; oContact.Save(); }
Answer: C
Explanation: The delegate is correctly declared with appropriate parameters: private void HandleContactSaved(object sender, EventArgs e)
The association between the delegate and the event is correctly created with the += operator: oContact.ContactSaved += new EventHandler (HandleContactSaved)
Note: An event handler is a method that is called through a delegate when an event is raised, and you must create associations between events and event handlers to achieve your desired results. In C# the += operator is used to associate a delegate with an event..
Reference: 70-306/70-316 Training kit, Implementing Event Handlers, Pages 143-144
Incorrect Answers
A: The declaration of the delegate do not contain any parameters. private void HandleContactSaved()
B: There is no association made between the delegate and the event.
www.correctexams.com
-8-
Fast Way to get your Certification
D: The association between the delegate an the event is incorrect.
The += operator must be used: new EventHandler(HandleContactSaved)
QUESTION NO: 6
You use Visual Studio .NET to develop a Windows-based application that interacts with a Microsoft
SQL Server database. Your application contains a form named CustomerForm. You add the following design-time components to the form:
•
•
•
•
SqlConnection object named TestKingConnection.
SqlDataAdapter object named TestKingDataAdapter.
DataSet object named TestKingDataSet.
Five TextBox controls to hold the values exposed by TestKingDataSet.
At design time, you set the DataBindings properties of each TextBox control to the appropriate column in the DataTable object of TestKingDataSet. When you test the application, you can successfully connect to the database. However, no data is displayed in any text boxes.
You need to modify your application code to ensure that data is displayed appropriately. Which behavior should occur while the CustomerForm.Load event handler is running?
A.
B.
C.
D.
E.
Execute the Add method of the TextBoxes DataBindings collection and pass in TestKingDataSet.
Execute the BeginInit method of TestKingDataSet.
Execute the Open method of
TestKingConnection.
Execute the FillSchema method of TestKingDataAdapter and pass in TestKingDataSet.
Execute the Fill method of TestKingDataAdapter and pass in TestKingDataSet.
Answer: E
Explanation: Dataset is a container; therefore, you need to fill it with data. You can populate a dataset by calling the Fill method of a data adapter.
Reference: Visual Basic and Visual C# Concepts, Introduction to Datasets
QUESTION NO: 7
You use Visual Studio .NET to create a Windows-based application. The application includes a form named TestKingForm.
TestKingForm contains 15 controls that enable users to set basic configuration options for the application. You design these controls to dynamically adjust when users resize TestKingForm. The controls automatically update their size and position on the form as the form is resized. The initial size of the form should be 659 x 700 pixels.
www.correctexams.com
-9-
Fast Way to get your Certification
If ConfigurationForm is resized to be smaller than 500 x 600 pixels, the controls will not be displayed correctly. You must ensure that users cannot resize ConfigurationForm to be smaller than 500 x 600 pixels. Which two actions should you take to configure TestKingForm? (Each correct answer presents part of the solution. Choose two)
A.
B.
C.
D.
E.
F.
G.
H.
Set the MinimumSize property to “500,600”.
Set the MinimumSize property to “650,700”.
Set the MinimizeBox property to True.
Set the MaximumSize property to “500,600”.
Set the MaximumSize property to “650,700”.
Set the MaximumBox property to True.
Set the Size property to “500,600”.
Set the Size property to “650,700”.
Answer: A, H
Explanation:
A: The Form.MinimumSize Property gets or sets the minimum size the form can be resized to. It should be set to "500, 600".
H: We use the size property to set the initial size of the form. The initial size should be set to "650, 700".
Reference:
.NET Framework Class Library, Form.MinimumSize Property [C#]
.NET Framework Class Library, Form.Size Property [C#]
Incorrect Answers
B: The initial size is 650 x 750. The minimal size should be set to "500,600".
C: The minimize button will be displayed, but it will not affect the size of the form.
D, E: There is no requirement to define a maximum size of the form.
F: The maximize button will be displayed, but it will not affect the size of the form.
G: The initial size should be 650 x 700, not 500 x 600.
QUESTION NO: 8
You responsible for maintaining an application that was written by a former colleague at TestKing.
The application reads from and writes to log files located on the local network. The original author included the following debugging code to facilitate maintenance: try {
Debug.WriteLine(“Inside Try”); throw(new IOException());} catch (IOException e) {
Debug.WriteLine (“IOException Caught”);} catch (Exception e) {
Debug.WriteLine(“Exception Caught”);}
www.correctexams.com
- 10 -
Fast Way to get your Certification finally {
Debug.WriteLine (“Inside Finally”);}
Debug.WriteLine (“After End Try”);
Which output is produced by thus code?
A. Inside Try
Exception Caught
IOException Caught
Inside Finally
After End Try
B. Inside Try
Exception Caught
Inside Finally
After End Try
C. Inside Try
IOException Caught
Inside Finally
After End Try
D. Inside Try
IOException Caught
Inside Finally
Answer: D
Explanation: First the try code runs. Then one single exception occurs, not two. Then the finally code is run, and not the code after finally.
Reference: 70-306/70-316 Training kit, Creating an Exception handler, page 235
Incorrect Answers
A: An exception can only be caught once, not twice.
B: The code after finally will not be run if an exception occurs.
C: The code after finally will not be run if an exception occurs.
QUESTION NO: 9
You use Visual Studio .NET to create a Windows-based application for online gaming. Each user will run the client version of the application on his or her local computer. In the game, each user controls two groups of soldiers, Group1 and Group2.
You create a top-level menu item whose caption is Groups. Under this menu, you create two submenus. One is named group1Submenu, and its caption is Group 1. The other is named group2Submenu, and its caption is Group 2. When the user select the Groups menu, the two submenus will be displayed. The user can select only one group of soldiers at a time.
www.correctexams.com
- 11 -
Fast Way to get your Certification
You must ensure that a group can be selected either by clicking the appropriate submenu item or by holding down the ALT key and pressing 1 or 2. You must also ensure that the group currently select will be indicated by a dot next to the corresponding submenu item. You do not want to change the caption text of any of your menu items.
Which four actions should you take? (Each correct answer presents part of the solution. Choose four)
A. Set group1Submenu.Text to “Group &1”.
Set group2Submenu.Text to “Group &2”.
B. Set Group1.ShortCut to “ALT1”.
Set Group2.ShortCut to “ALT2”.
C. In the group1Submenu.Click event, place the following code segment: group1Submenu.DefaultItem = true;
In the group2Submenu.Click event, place the following code segment: group2Submenu.DefaultItem = true;
D. In the group1Submenu.Click event, place the following code segment: group2Submenu.DefaultItem = false;
In the group2Submenu.Click event, place the following code segment: group1Submenu.DefaultItem = false;
E. In the group1Submenu.Click event, place the following code segment: group1Submenu.Checked = true;
In the group2Submenu.Click event, place the following code segment: group2Submenu.Checked = true;
F. In the group1Submenu.Click event, place the following code segment: group2Submenu.Checked = false;
In the group2Submenu.Click event, place the following code segment: group1Submenu.Checked = false;
G. Set group1Submenu.RadioCheck to True.
Set group2Submenu.RadioCheck to True.
H. Set group1Submenu.RadioCheck to False.
Set group2Submenu.RadioCheck to False.
Answer: A, E, F, G
Explanation:
A: The & sign is used to define the required Access key.
E, F: The menu item's Checked property is either true or false, and indicates whether the menu item is selected. We should set the clicked Submenu Checked property to True, and the other Submenu
Checked property to False.
G: The menu item's RadioCheck property customizes the appearance of the selected item: if RadioCheck is set to true, a radio button appears next to the item;
Reference:
Visual Basic and Visual C# Concepts, Adding Menu Enhancements to Windows Forms
Visual Basic and Visual C# Concepts, Introduction to the Windows Forms MainMenu Component
Incorrect Answers
B: This is not the way to define Access keys. The & sign must be used.
www.correctexams.com
- 12 -
Fast Way to get your Certification
C, D: We are not interested in defining default items. We want to mark items as checked.
H: The RadioCheck property must be set to True for both menu items.
QUESTION NO: 10
You use Visual Studio .NET to create a control that will be used on several forms in your application.
It is a custom label control that retrieves and displays your company’s current stock price.
The control will be displayed on many forms that have different backgrounds. You want the control to show as much of the underlying form as possible. You want to ensure that only the stock price is visible. The rectangular control itself should not be visible.
You need to add code to the Load event of the control to fulfill these requirements. Which two code segments should you use? (Each correct answer presents part of the solution. Choose two)
A.
B.
C.
D.
E.
this.BackColor = Color.Transparent; this.ForeColor = Color.Transparent; this.BackImage = null; this.SetStyle(ControlStyles.UserPaint, false); this.SetStyle(ControlStyles.SupportsTransparentBackColor, true);
Answer: A, E
Explanation:
To give your control a transparent backcolor:
1.
Call the SetStyle method of your form in the constructor. this.setStyle(ControlStyles.SupportsTransparentBackColor, true);
This will enable your control to support a transparent backcolor.
2. Beneath the line of code you added in step 1, add the following line. This will set your control's
BackColor to Transparent. : this.BackColor = Color.Transparent;
Reference: Visual Basic and Visual C# Concepts, Giving Your Control a Transparent Background
QUESTION NO: 11
You create a Windows Form named TestKingForm. The form enables users to maintain database records in a table named TestKing.
You need to add several pairs of controls to TestKingForm. You must fulfill the following requirements: www.correctexams.com
- 13 -
Fast Way to get your Certification
•
•
•
•
•
•
Each pair of controls must represent one column in the TestKing table.
Each pair must consist of a TextBox control and a Label control.
The LostFocus event of each TextBox control must call a procedure named UpdateDatabase.
Additional forms similar to TestKingForm must be created for other tables in the database.
Application performance must be optimized.
The amount of necessary code must be minimized.
What should you do?
A. Create and select a TextBox control and a Label control.
Write the appropriate code in the LostFocus event of the TextBox control.
Repeatedly copy and paste the controls into TestKingForm until every column in the TestKing table has a pair of controls.
Repeat this process for the other forms.
B. Add a TextBox control and a Label controls to TestKingForm.
Write the appropriate code in the LostFocus event of the TextBox control.
Create a control array form the TextBox control and the Label control.
At run time, add additional pairs of controls to the control array until every column in the TestKing table has a pair of controls.
Repeat this process for the other forms.
C. Create a new user control that includes a TextBox control and a Label control.
Write the appropriate code in the LostFocus event of the TextBox control.
For each column in the TestKing table, add one instance of the user control to the TestKingForm.
Repeat this process for the other forms.
D. Create a new ActiveX control that includes a TextBox control and a Label control.
For each column in the TestKing table, add one instance of the ActiveX control to TestKingForm.
Repeat this process for the other forms.
Answer: C
Explanation: We combine multiple Windows Form controls into a single control, called user control. This is the most efficient solution to reuse functionality in this scenario.
Note: Sometimes, a single control does not contain all of the functionality you need. For instance, you might want a control that you can bind to a data source to display a first name, last name, and phone number, each in a separate TextBox. Although it is possible to implement this logic on the form itself, it might be more efficient to create a single control that contains multiple text boxes, especially if this configuration is needed in many different applications. Controls that contain multiple Windows Forms controls bound together as a single unit are called user controls.
Reference: 70-306/70-316 Training kit, Inheriting from UserControl, Page 345
Incorrect Answers
A: Only the controls, not the code of the control will be copied.
B: This is not the best solution. With a user control we could avoid writing code that are executed at run time. www.correctexams.com
- 14 -
Fast Way to get your Certification
D: ActiveX controls should be avoided in Visual Studio .NET. They are less efficient.
QUESTION NO: 12
You are a developer for a TestKing Inc that provides free software over the Internet. You are developing en e-mail application that users all over the world can download.
The application displays text strings in the user interface. At run time, these text strings must appear in the language that is appropriate to the locale setting of the computer running the application.
You have resources to develop versions of the application for only four different cultures. You must ensure that your application will also be usable by people of other cultures.
How should you prepare the application for deployment?
A. Package a different assembly for each culture.
B. Package a different executable file for each culture.
C. Package a main assembly for source code and the default culture.
Package satellite assemblies for the other cultures.
D. Package a main assembly for source code.
Package satellite assemblies for each culture.
Answer: C
Explanation: When you build a project, the resource files are compiled and then embedded in satellite assemblies, or assemblies which contain only the localized resources. The fallback resources are built into the main assembly, which also contains the application code.
Reference:
Visual Basic and Visual C# Concepts, What's New in International Applications
Visual Basic and Visual C# Concepts, Introduction to International Applications in Visual Basic and Visual
C#
Incorrect Answers
A: A main assembly is needed.
B: Assemblies not executables are used.
D: The main assembly contains the fallback resources (including default culture).
QUESTION NO: 13
You use Visual Studio .NET to develop an application that contains 50 forms. You create a procedure named PerformCalculations, which writes the results of several internal calculations to the Debug window. These calculations take more than one minute to execute.
www.correctexams.com
- 15 -
Fast Way to get your Certification
You want to be able to compile two versions of the application, one for debugging and the other for release. The debugging version should execute the calculations. The release version should not include or compile the calculations. You want to accomplish this goal by using the minimum amount of code.
Which two actions should you take? (Each correct answer presents part of the solution. Choose two)
A. Use the following code segment:
#if DEBUG
// Insert code to perform calculations.
#endif
B. Use the following code segment: if (DEBUG) {
// Insert code to perform calculations.
}
C. Use the following code segment at the top of the module:
#define DEBUG
D. Add DEBUG = true to the Command Line Arguments box on the Debugging pane of the Project
Properties dialog box.
E. Ensure that the Conditional Compilation Constants option in the Build pane of the Project
Properties dialog box contains the value DEBUG.
F. Ensure that the Conditional Compilation Constants options in the Build pane of the Project
Properties dialog box includes the value TRACE.
Answer: A, E
Explanation:
A: We should use the #if DEBUG conditionally statement wherever we want to use code that print debug information. E: We enable debugging by entering DEBUG to the Conditional Compilation Constants option.
Reference:
Visual Basic and Visual C# Concepts, Compiling Conditionally with Trace and Debug
C# Language Specification, Conditional compilation directives
Incorrect Answers
B: Incorrect syntax.
C: This would achieve the goal as well. But compared to E) it would not minimize code.
D: This is not how it is done in C#. In Visual Basic .NET you could use #CONST DEBUG = true. In
Visual C# however, you must use the DEBUG = true statement.
F: Traces are used to trace program execution, not to print debug information.
QUESTION NO: 14
You use Visual Studio .NET to create a Windows-based application that will track testking sales. The application’s main object is named Testking. The testking class is created by the following definition: public class Testking {
www.correctexams.com
- 16 -
Fast Way to get your Certification
}
You write code that sets properties for the Testking class. This code must be executed as soon as an instance of the Testking class is created.
Now you need to create a procedure in which you can place your code. Which code segment should you use?
A.
B.
C.
D.
E.
F.
public public public public public public Testking() void Testking () bool Testking ()
New()
Testking New()
Testking Testking()
Answer: A
Explanation: We must create a constructor for the class. We wrote a method whose name is the same as the name of the class, and we specify not return type, not even void.
Reference: Visual C# Step by step, page 144
Incorrect Answers
B, C:
We cannot specify any return type, not even void, when we define a constructor for a class.
D: The constructor must have the name of the class.
E; F: Incorrect syntax. This is not the way to create a constructor.
QUESTION NO: 15
You develop a Windows-based application by using Visual Studio .NET. The application includes a form named TestKingForm and a class named Contact. TestKingForm includes a button named cmdCreateContact. You must ensure that your application creates an instance of Contact when a user clicks this button. You want to write the most efficient code possible.
Which code segment should you use?
A.
B.
C.
D.
Contact contact = new Object();
Contact contact = new Contact;
Object contact = new Contact;
Contact contact = new Object;
Answer: B
Explanation: We declare that contact should be of type Contact and we use the Contact constructor.
Contact contact = new Contact;
www.correctexams.com www.correctexams.com - 17 -
Fast Way to get your Certification
Reference:
Incorrect Answers
A, D: The constructor of the class has the same name as the class, namely Contact.
C: We must specify that the object should be an instance of the Class object, not any object.
Object contact = new Contact;
QUESTION NO: 16
As a developer at TestKing inc. you develop a Windows-based application by using Visual Studio
.NET. The application tracks information about customers, orders, and shipping. Ten users will use this application on the client computers running Windows 2000 Professional.
You deploy the application by copying the contents of the project’s \bin folder to the client computers.
Nine users report that the application runs as expected. One user receives the following error message when the application is first executed:
“The dynamic link library mscoree.dll could not be found in the specified path C\Program
Files\Orders
App;.;C:\WINNT\System32;C:\WINNT\System;C:\WINNT\System32;C:\WINNT;C:\WINNT\System
32\Wbem.”
You need to correct this problem on the client computer. What should you do?
A.
B.
C.
D.
Install MDAC 2.7.
Install Internet Explorer 6.
Install the redistribute package for the .NET Framework.
Recopy the contents of the \bin folder.
Answer: C
Explanation: If you attempt to run a console application or a Windows Form application from a computer on which the .NET runtime is not installed, you will receive the error "Unable To Locate DLL: The dynamic link library mscoree.dll could not be found in the specified path..." To solve this problem, install the .NET runtime on the computer and try running the application again.
Note: Mscoree.dll contains the common language runtime.
Reference: Office Talk, Introducing .NET to Office Developers
Incorrect Answers
A: MDAC (Microsoft Data Access Components) later could be required if the application uses additional features such as ASP.NET, COM+ services, and SQL Server .NET Data Provider. MDAC 2.6 could be required on the client. MDAC 2.7 could be required on the server. Furthermore an older version of
MDAC would not produce the error of this scenario.
B: A lack of Internet Explorer 6.0 would not produce this error.
D: This would not resolve the problem
www.correctexams.com
- 18 -
Fast Way to get your Certification
QUESTION NO: 17
You develop a Windows-based application by using Visual Studio .NET. The application includes numerous method calls at startup. After optimizing your application code, you test the application on a variety of client computers. However, the startup time is too slow.
You must ensure that your application starts as quickly as possible the first time it runs. What should you do?
A. Precompile your application by using the Native Image Generator (Ngen.exe):
Install the precompiled application on the client computers.
B. Install your application on the client computers.
Precompile your application by using the Native Image Generator (Ngen.exe).
C. Precompile your application by using the JIT compiler.
Install the precompiled application on the client computers.
D. Install your application on the client computers.
Precompile your application by using the JIT compiler.
Answer: A
Explanation: A native image is a precompiled version of a .NET assembly. In situations where performance is critical, you might be able to achieve a somewhat higher level of performance by precompiling your application to native code. The Native Image Generator (ngen.exe) creates a native image from a managed assembly and installs it into the native image cache on the local computer. Running Ngen.exe on an assembly allows the assembly to load and execute faster, because it restores code and data structures from the native image cache rather than generating them dynamically. Pre-compiling assemblies with Ngen.exe can improve the startup time for applications
Reference: .NET Framework Tools, Native Image Generator (Ngen.exe)
Incorrect Answers
B: The precompilation takes place once on the source computer, not on the client computers.
C, D: The time's Just-In-Time (JIT) cannot be used to precompile program. JIT is applied at runtime.
Note: When you compile a .NET application, it is not compiled to binary machine code; rather, it is converted to IL, which is a low-level set of instructions understood by the common language run time.
When execution starts, the first bit of code that needs to be executed is loaded into memory and compiled into native binary code from IL by the common language run time's Just-In-Time (JIT) compiler.
QUESTION NO: 18
You use Visual Studio .NET to create an accounting application. Within this application, you are debugging a function named TestKingValidate. This function contains several dozen variables and objects. One of the variables is named bValidationStatus.
www.correctexams.com www.correctexams.com - 19 -
Fast Way to get your Certification
You create a breakpoint at the top of TestKingValidate and run the application within the Visual
Studio .NET IDE.
As you steep through the code in TestKingValidate, you need to view the contents of the bValidationStatus variable. However, you want to avoid seeing the contents of the other variables and objects in the function. You also need to complete the debugging process as quickly as possible.
What should you do?
A. Open the Locals window.
B. From the Command window, print the contents of bValidationStatus by using ? bValidationStatus. C. Open the QuickWatch dialog box for bValidationStatus.
D. Add a watch expression for bValidationStatus.
Answer: C
Explanation: You can quickly evaluate a variable by using the QuickWatch dialog box. The QuickWatch dialog box shows you the Name, Value, and Type of a single variable, and gives you the option of adding the variable to the Watch window.
Reference: 70-306/70-316 Training kit, The Watch Window, Pages 214-215
Incorrect Answers
A: The Locals Windows would display all variables of the code in the TestKingValidate procedure.
B: This would only display the current value. The requirements of the scenario is that we need to view the variable as we step through the code, not just at a single point of time.
D: This proposed solution would require more effort.
QUESTION NO: 19
You develop an application that invokes a procedure named ProcessRecords. You implement the
Trace class to log any errors thrown by ProcessRecords. You direct the Trace output to a local log file named ErrorLog.txt by using the following code segment:
StreamWriter oWriter = new StreamWriter(
File.Open(logfilePath, FileMode.Append));
TextWriterTraceListener oListener = new TextWriterTraceListener(oWriter);
Trace.Listeners.Add(oListener);
try {
ProcessRecords();
} catch (Exception oEx) {
Trace.WriteLine(“Error: “ + oEx.Message;
}
finally {
}
www.correctexams.com
- 20 -
Fast Way to get your Certification
Now you need to add code to your finally construct to write all output in the ErrorLog.txt file and then close the file. You want to write the minimum amount of code to achieve this goal.
Which code segment should you use?
A. oWriter.Close();
B. Trace.Flush(); oWriter.Close(); C. Trace.AutoFlush = true; oWriter.Close(); D. oWriter.AutoFlush = true; oWriter.Close(); Answer: B
Explanation: When the code in the code above executes, all of the output from the Trace class will be written to oWriter. In order for them to actually be written to the file, however, you must flush the Trace buffer by calling the Flush method: Trace.Flush();
Then we close the listener.
Reference: .NET Framework Class Library, StreamWriter.AutoFlush Property [C#]
Incorrect Answers
A: The content of the listener must be flushed in order to be written to a file.
C: The Trace.Autoflush = true option would cause the buffer to be flushed after every write. However, this statement should not be put in the finally block. It should be used before traces are written to oWriter. D: The command is Trace.Autoflush = true, not Listener.Autoflush = true. Furthermore this statement should not be put in the finally code here..
QUESTION NO: 20
You develop a Visual Studio .NET application that contains a function named TestKingUpdate. For debugging purposes, you need to add an entry to a log file whenever TestKingUpdate is executed. The log file is named DebugLog.txt. For maximum readability, you must ensure that each entry in
DebugLog.txt appears on a separate line.
Which code segment should you use?
A. StreamWriter oWriter = new StreamWriter(File.Open(
@”C:\DebugLog.txt”, FileMode.Append));
TextWriterTraceListener oListener = new TextWriterTraceListener(oWriter);
www.correctexams.com
- 21 -
Fast Way to get your Certification
Debug.Listeners.Add(oListener);
Debug.WriteLine(“TestKingUpdate “ + DateTime.Now.ToString);
B. StreamWriter oWriter = new StreamWriter(File.Open(
“C:\\DebugLog.txt”, FileMode.Append));
TextWriterTraceListener oListener = new TextWriterTraceListener(oWriter);
Debug.Listeners.Add(oListener);
Debug.Write(“TestKingUpdate “ + DateTime.Now.ToString);
C. TextWriterTraceListener oListener = new TextWriterTraceListener(); oListener.Name = “C:\\DebugLog.txt”;
Debug.Listeners.Add(oListener);
Debug.WriteLine(“TestKingUpdate “ + DateTime.Now.ToString);
D. TextWriterTraceListener oListener = new TextWriterTraceListener(); oListener.Name = “C:\\DebugLog.txt”;
Debug.Listeners.Add(oListener);
Debug.Write(“TestKing“ + DateTime.Now.ToString);
Answer: C
Explanation: All debug and trace output are directed to the Listeners collections. The
TextWriterTraceListener class receives the trace output and writes its output as text, either to a Stream object or to a TextWriter object.
Reference: 70-306/70-316 Training kit, Logging Trace Output to Text, Page 221
Incorrect Answers
A, B: StreamWriter is designed for character output in a particular Encoding, not to write to log file.
D: This proposed solution would not put each entry on a separate line. We must Debug.WriteLine, not
DebugWrite.
QUESTION NO: 21
Your TestKing project team uses Visual Studio .NET to create an accounting application. Each team member uses the Write method of both the Debug class and the Trace class to record information about application execution in the Windows 2000 event log.
You are performing integration testing for the application. You need to ensure that only one entry is added to the event log each time a call is made to the Write method of either the Debug class or the
Trace class.
What are two possible code segments for you to use? (Each correct answer presents a complete solution. Choose two)
www.correctexams.com
- 22 -
Fast Way to get your Certification
A. EventLogTraceListener myTraceListener = new EventLogTraceListener(“myEventLogSource”);
B. EventLogTraceListener myDebugListener = new EventLogTraceListener(“myEventLogSource”);
Debug.Listeners.Add(myDebugListener);
C. EventLogTraceListener myTraceListener = new EventLogTraceListener(“myEventLogSource”);
Debug.Listeners.Add(myTraceListener);
Trace.Listeners.Add(myTraceListener);
D. EventLogTraceListener myDebugListener = new EventLogTraceListener(“myEventLogSource”);
EventLogTraceListener myTraceListener = new EventLogTraceListener(“myEventLogSource”);
Debug.Listeners.Add(myDebugListener);
Trace.Listeners.Add(myTraceListener);
Answer: A, B
Explanation: An EventLogTraceListener redirects output to an event log. Debug and trace share the same
Listeners collection, so if you add a listener object to a Debug.Listeners collection in your application, it gets added to the Trace.Listeners collection as well, and vice versa.
Reference:
Visual Basic and Visual C# Concepts, Trace Listeners
Visual Basic and Visual C# Concepts, Creating and Initializing Trace Listeners
Incorrect Answers
C: Add a listener to both the Debug.Listeners collection and the Trace.Listeners collection the listener would receive duplicate messages.
D: If we create a separate listener for trace messages and debug messages we would get duplicate messages
QUESTION NO: 22
You use Visual Studio .NET to create a Windows-based application. The application includes a form named TestKingProcedures (TKP). TKP allows users to enter very lengthy text into a database. When users click the Print button located on TKP, this text must be printed by the default printer. You implement the printing functionality by using the native .NET System Class Libraries with all default settings. Users report that only the first page of the text is being printed.
How should you correct this problem?
A.
B.
C.
D.
In the BeginPrint event, set the HasMorePages property of the PrintEventArgs object to True.
In the EndPrint event, set the HasMorePages property of the PrintEventArgs object to True.
In the PrintPage event, set the HasMorePages property of the PrintPageEventArgs object to True.
In the QueryPageSettings event, set the HasMorePages property of the QueryPageSettingEventArgs object to True.
www.correctexams.com
- 23 -
Fast Way to get your Certification
Answer: C
Explanation: PrintDocument.PrintPage Event occurs when the output to print for the current page is needed. This event has the HasMorePages property which gets or sets a value indicating whether an additional page should be printed.
Reference:
.NET Framework Class Library, PrintDocument Class [Visual Basic]
.NET Framework Class Library, PrintDocument.PrintPage Event [Visual Basic]
QUESTION NO: 23
You use Visual Studio .NET to create an application that tracks support incidents for your technical support department. You implement the Trace class to write information about run-time errors in a local log file. You also implement a TraceSwitch object named MySwitch, which can turn Trace lagging on and off as needed. To maximize application performance, you ensure that MySwitch is disabled by default.
You set your Configuration Manager to Release. You compile the application and deploy it to a shared folder on your company intranet. Fifty users access the application from a shortcut on their desktops. One user receives error messages while running the application. You decide to enable verbose trace logging within the application for that user. You must ensure that you do not affect application performance for the other users.
Which action or actions should you take? (Choose all that apply)
A. Set your Configuration Manager to Debug.
Compile your application and deploy it locally on the user’s computers.
Create a new shortcut on the user’s desktop to access the local copy of the application.
B. Copy the deployed version of the application from the shared folder.
Deploy it locally on the user’s computer.
Create a new desktop shortcut on the user’s desktop to access the local copy of the application.
C. Edit the .config file for the application on the user’s computer to enable MySwitch with a value of 4.
D. Edit the .config file for the application on the shared folder to enable MySwitch with a value of 4.
E. Start the application with the /d:TRACE=TRUE command line option.
F. Start the application with the /TRACE MySwitch 4 command line option.
Answer: B, C
Explanation: Trace switches can be turned on and off after your application has been compiled and distributed. Trace switches are configured by manipulating the application .config file. The .config file must be located in the same folder as the executable. We must therefore make a local copy of the deployed folder
(B).
www.correctexams.com
- 24 -
Fast Way to get your Certification
For TraceSwitch objects, the values 0, 1, 2, 3, and 4 correspond to TraceLevel.Off, TraceLevel.Error,
TraceLevel.Warning, TraceLevel.Info, and TraceLevel.Verbose, respectively. We must configure a local copy of the .config file and enable MySwitch with a value of 4.. (C)
Reference: 70-306/70-316 Training kit, Configuring Trace Switches, Page 226
Incorrect Answers
A: There is no need to recompile the application. We just need a local copy of the deployment directory.
D: We cannot use the .config file the shared folder. It would affect all users.
E: The /d:TRACE=True flag is used as a the compiler command line, not to start the application.
Furthermore, this flag applies to Visual Basic .NET, not to Visual C# .Net.
F: There is no command line option /TRACE
QUESTION NO: 24
You company TestKing assigns you to modify a Visual Studio .NET application that was created by a former colleague. However, when you try to build the application, you discover several syntax errors.
You need to correct the syntax errors and compile a debug version of the code so the application can be tested.
Before compiling, you want to locate each syntax error as quickly as possible.
What should you do?
A. Select each error listed in the Task List window.
B. Open the Application event log from the Visual Studio .NET Server Explorer window. Select each error listed.
C. Run the application in Debug mode. Each time an error is encountered, correct it and continue debugging the application.
D. Select Build Solution from the Build menu. When the build fails, correct each error listed in the
Output window.
E. Select Build Comment Web Pages from the Tools menu. Select each function listed in the report that is generated.
Answer: A
Explanation: The task list window contains information which helps you to organize and manage the work of building your application. Among other things it will include each syntax error of the application.
Reference:
Visual Studio, Task List Window
Visual Studio, Build Comment Web Pages Dialog Box
Incorrect Answers
B: Event logs would not contain information on syntactical errors.
C: Syntax errors are corrected in Debug mode.
D: The errors are listed in the Task List windows. The text in the Output windows is more extensive, and the syntax errors are harder to spot.
www.correctexams.com
- 25 -
Fast Way to get your Certification
E: Build Comment Web Pages would not list the syntax errors. It allows you to create a series of .htm pages that display the code structure within projects and solutions, objects and interfaces defined in a project, and members. The .htm pages also display information you have included in your code using the code comment syntax.
QUESTION NO: 25
You development team used Visual Studio .NET to create an accounting application, which contains a class named TestKingAccounts. This class instantiates several classes from a COM component that was created by using Visual Basic 6.0. Each COM component class includes a custom method named
ShutDownObject that must be called before terminating references to the class.
Software testers report that the COM component appears to remain in memory after the application terminates. You must ensure that the ShutDownObject method of each COM component class is called before TestKingAccounts is terminated.
What should you do?
A. Add code to the Terminate event of TestKingAccounts to call the ShutDownObject method of each
COM component class.
B. Find each location in your code where a reference to TestKingAccounts is set to null or goes out of scope. Add code after each instance to manually invoke the Visual Studio .NET garbage collector.
C. Add a destructor to TestKingAccounts.
Add code to the destructor to call the ShutDownObject method of each COM component class.
D. Add the procedure private void Finally() to TestKingAccounts.
Add code to the procedure to call the ShutDownObject method of each COM component class.
Answer: C
Explanation: Be creating a destructor for TestKingAccounts class we can ensure that appropriate actions are performed before TestKingAccounts is terminated.
Reference: C# Language Specification, Destructors
QUESTION NO: 26
You develop a Windows-based application by using Visual Studio .NET. You use TestKing’s intranet to deploy the application to client computers. You use the security configuration of the .NET
Framework to configure security for you application at the enterprise policy level.
Virus attacks cause the IT manager at TestKing to tighten security at the machine level. Users report that they can no longer execute your application.
www.correctexams.com
- 26 -
Fast Way to get your Certification
How should you correct this problem?
A. Include the LevelFinal attribute in the intranet code group policy at the enterprise level by using the
Permission View tool (Permview.exe).
B. Include the Exclusive attribute in the intranet code group policy at the enterprise level by using the
Permission View tool (Permview.exe).
C. Include the LevelFinal attribute in the intranet code group policy at the enterprise level by using the
Code Access Security Policy tool (Caspol.exe).
D. Include the Exclusive attributes in the intranet code group policy at the enterprise level by using the
Code Access Security Policy tool (Caspol.exe).
Answer: C
Explanation: The Code Access Security Policy tool (Caspol.exe) enables users and administrators to modify security policy for the machine policy level, the user policy level, and the enterprise policy level. If we apply the LevelFinal attribute at the enterprise level, any code group at the machine level will not be evaluated even if a machine level administrator has made changes..
Note: When LevelFinal is set to on, indicates that no policy level below the level in which the added or modified code group occurs is considered. This option is typically used at the machine policy level. For example, if you set this flag for a code group at the machine level and some code matches this code group’s membership condition, Caspol.exe does not calculate or apply the user level policy for this code.
Note: Reference:
.NET Framework Tools, Code Access Security Policy Tool (Caspol.exe)
Security Policy Best Practices, http://www.gotdotnet.com/team/clr/SecurityPolicyBestPractices.htm
.NET Framework Tools, Permissions View Tool (Permview.exe)
Incorrect Answers
A, B: The Permissions View tool is used to view, not to configure, the minimal, optional, and refused permission sets requested by an assembly.
D: When exclusive is set to on, it indicates that only the permission set associated with the code group you are adding or modifying is considered when some code fits the membership condition of the code group.
QUESTION NO: 27
You use Visual Studio .NET to develop a Windows-Bases application named PatTrac. It uses the security class libraries of the .NET Framework to implement security. PatTrac will run within the context of a Windows 2000 domain named MedicalOffice. Calls to a remote Windows 2000 domain named TestKing will occur during the execution of PatTrac.
You want PatTrac to log on to the TestKing domain by using a generic user account.
What should you do?
A. Create a new instance of the WindowsImpersonationContext class by calling the Impersonate method of the Genericidentity object and passing the token of the user whom you want to impersonate. www.correctexams.com
- 27 -
Fast Way to get your Certification
B. Create a new instance of the WindowsImpersonationContext class by calling the Impersonate method of the WindowsIdentify object and passing the token of the user whom you want to impersonate. C. Create a new instance of the ZoneIdentifyPermission class by calling the Impersonate method of the
GenericPrincipal object and passing the token of the user whom you want to impersonate.
D. Create a new instance of the ZoneIdentifyPermission class by calling the Impersonate method of the
WindowsPrincipal object and passing the token of the user whom you want to impersonate.
Answer: B
Explanation: We must impersonate another user. The WindowsImpersonationContext Class, not
ZoneIdentifyPermission class, should be used. Furthermore the Impersonate method must be used on a
Windowsidentity object, not on a Genericidentity object.
Reference: .NET Framework Class Library, WindowsImpersonationContext Class [C#]
QUESTION NO: 28
You use Visual .NET to develop a Windows-based application whose project name is TestKingMgmt.
You create an application configuration file that will be installed on the client computer along with
TestKingMgmt.
You must ensure that the settings in the application configuration file are applied when
TestKingMgmt is executed.
What should you do?
A. Name the configuration file TestKingMgmt.exe.confing and copy it to the Windows\System32 folder. B. Name the configuration file TestKingMgmt.config and copy it to the Windows\System32 folder.
C. Name the configuration file TestKingMgmt.exe.config and copy it to the application folder.
D. Name the configuration file TestKingMgmt.config and copy it to the application folder.
E. Name the configuration file TestKingMgmt.exe.config and copy it to the global assembly cache.
Answer: C
Explanation: The configuration file for an application hosted by the executable host is in the same directory as the application. The name of the configuration file is the name of the application with a .config extension.
In this scenario the configuration file should named TestKingMgmt.exe.config and be placed in the application folder.
Reference: .NET Framework Developer's Guide, Application Configuration Files
QUESTION NO: 29
You use Visual Studio .NET to develop a Windows-based application. The application will implement a role-based authorization scheme that is based on a Microsoft SQL Server database of user names.
www.correctexams.com
- 28 -
Fast Way to get your Certification
Users will enter their user names in a text box named userName and logon screen.
You must ensure that all users are assigned the Supervisor rule and the TK role by default.
Which code segment should you use?
A. WindowsIdentity identity = new WindowsIdentity.GetCurrent(); string[] RoleArray =
{“Supervisor”, “TK”};
GenericPrincipal principal = new GenericPrincipal(identity, RoleArray);
B. GenericIdentity identity = new GenericIdentity(userName.Text); string[] RoleArray =
{“Supervisor”, “TK”};
WindowsPrincipal principal = new WindowsPrincipal(identity);
C. GenericIdentity identity = new GenericIdentity(userName.Text); string[] RoleArray =
{“Supervisor”, “TK”};
GenericPrincipal principal = new GenericPrincipal(identity, RoleArray);
D. WindowsIdentity identity = new WindowsIdentity.GetAnonymous(); string[] RoleArray =
{“Supervisor”, “TK”};
WindowsPrincipal principal = new GenericPrincipal(identity, RoleArray);
Answer: C
Explanation: The GenericPrincipal Class represents a generic principal. This class represents the roles of the current user.
Note: GenericPrincipal objects represent any user authorization scheme independent of Windows domains, and as a result can be extended to work with user databases, even to interoperate with other platforms.
Reference:
.NET Framework Class Library, GenericPrincipal Class [C#]
.NET Framework Class Library, WindowsPrincipal Class [C#]
Incorrect Answers
A: We should not use the current identity, instead we should use the identity entered in the UserName textbox. B: The WindowsPrincipal class allows code to check the Windows group membership of a Windows user.
It cannot be assign roles to a user.
www.correctexams.com
- 29 -
Fast Way to get your Certification
D: We should not use the anonymous identify, instead we should use the identity entered in the UserName textbox. QUESTION NO: 30
You create an assembly by using Visual Studio .NET. The assembly is responsible for writing and reading order entry information to and from an XML data file. The assembly also writes and reads values to and from the Windows registry while it is being consumed.
The assembly will be distributed to client computers by using your company, TestKing, intranet. All client computers are configured to implement the default .NET security policy.
You need to implement security in the assembly. What should you do?
A. Implement declarative security and execute the permission demand to allow access to the file system and Windows registry.
B. Implement declarative security and execute the minimum permission request to allow access to the file system and Windows registry.
C. Implement imperative security and execute the permission demand to allow access to the file system and Windows registry.
D. Implement imperative security and execute the minimum permission request to allow access to the file system and Windows registry.
Answer: B
Explanation: You can use declarative code access security to request permissions for the entire assembly.
SecurityAction flags that can be specified in an assembly-wide directive. When
SecurityAction.RequestMinimum is specified, it makes a request to the common language runtime to be granted the requested permission. If the requested permission is not granted by the security policy, the assembly will not execute. A SecurityAction.RequestOptional is similar, but the assembly will still run even if the requested permission is not granted. Specifying SecurityAction.RequestRefuse requests that the assembly be denied the specified permission. You must use the Assembly (assembly) directive when specifying these actions as follows:
Reference: 70-306/70-316 Training kit, Declarative Code Access Security, Pages 457-458
Incorrect Answers
A: There are only three Security actionAttributes targets for an assembly: RequestMinimumAssembly,
RequestOptionalAssembly, and RequestRefuseAssembly.
C, D: Imperative security does not work well to configure security for an entire assembly. In imperative security, permission to execute is demanded at run time.
QUESTION NO: 31
www.correctexams.com
- 30 -
Fast Way to get your Certification
You use Visual Studio .NET to create an application that uses an assembly. The assembly will reside on the client computer when the application is installed. You must ensure that any future applications installed on the same computer can access the assembly.
Which two actions should you take? (Each correct answer presents part of the solution. Choose two)
A.
B.
C.
D.
E.
F.
G.
Use XCOPY to install the assembly in the global assembly cache.
Use XCOPY to install the assembly in the Windows\Assembly folder.
Create a strong name for the assembly.
Recompile the assembly by using the Native Image Generator (Ngen.exe).
Modify the application configuration file to include the assembly.
Use a deployment project to install the assembly in the global assembly cache.
Use a deployment project to install the assembly in the Windows\System32 folder.
Answer: C, F
Explanation:
The global assembly cache stores assemblies specifically designated to be shared by several applications on the computer.
C: An assembly must have a strong name to be installed in the global assembly cache.
F: There are two ways to install an assembly into the global assembly cache:
• Using Microsoft Windows Installer 2.0. This could be achieved by a deployment project.
• Using the Global Assembly Cache tool (Gacutil.exe). This is not an option here.
Reference:
.NET Framework Developer's Guide, Working with Assemblies and the Global Assembly Cache
.NET Framework Developer's Guide, Installing an Assembly into the Global Assembly Cache
QUESTION NO: 32
You use Visual Studio .NET to create an application named TestKingClient. Another developer in your company creates a component named TestKingComponent. Your application uses namespaces exposed by TestKingComponent.
You must deploy both TestKingClient and TestKingComponent to several computers in your company’s accounting department. You must also ensure that TestKingComponent can be used by future client applications.
What are three possible ways to achieve your goal? (Each correct answer presents a complete solution. Choose three)
A. Deploy TestKingClient and TestKingComponent to a single folder on each client computer.
Each time a new client application is developed, place the new application in its own folder and copy
TestKingComponent to the new folder.
B. Deploy TestKingClient and TestKingComponent to a single folder on each client computer.
Each time a new client application is developed, place the new application in its own folder.
Edit TestKingClient.exe.config and add a privatePath tag that points to the folder where
TestKingComponent is located.
www.correctexams.com
- 31 -
Fast Way to get your Certification
C. Deploy TestKingClient and TestKingComponent to separate folders on each client computer.
In each client application that will use TestKingComponent, add the following code segment: using TestKingComponent;
D. Deploy TestKingClient and TestKingComponent to separate folders on each client computer.
Each time a new client application is developed, select Add Reference from the Tools menu and add a reference to TestKingComponent.
E. Deploy TestKingClient and Tes tKingComponent to separate folders on each client computer.
Register TestKingComponent on each client computer by using the RegSvr32 utility.
F. Deploy TestKingClient and TestKingComponent to separate folders on each client computer.
Add TestKingComponent to the global assembly cache.
Answer: A, D, F
Explanation:
A: XCOPY deployment of the TestKingComponent, we simply copy the component to the deployment folder of every application that requires the use of the components, enables the deployed application to use the component.
D: You can access any .NET or COM library on your system. The generalized scheme for accessing .NET or COM components is to create a reference to the type library. You can obtain a list of available type libraries in the Add Reference dialog box which is accessible on the Tools menu.
F: If you intend to share an assembly among several applications, you can install it into the global assembly cache. Reference:
70-306/70-316 Training kit, Accessing .NET and COM Type Libraries, Pages 386-387
.NET Framework Developer's Guide, Working with Assemblies and the Global Assembly Cache
C# Programmer's Reference, using Directive
Incorrect Answers
A: Just copying the component to the folder of the deployed application will not make the component accessible to the application.
B: This would not give the future client applications access to TestKingComponent.
C: The using keyword has two major uses: using Directive Creates an alias for a namespace. using Statement Defines a scope at the end of which an object will be disposed.
However, this would not make the component accessible.
E: RegSrv32 was used in before the introduction of Visual Studio .NET to register .dll file. It is no longer required..: QUESTION NO: 33
You use Visual Studio .NET to develop a Windows-based application called TestKingApp. Your application will display customer order information from a Microsoft SQL Server database. The orders will be displayed on a Windows Form in a data grid named DataGrid1. DataGrid1 is bound to a DataView object.
The Windows Form includes a button control named displayBackOrder. When users click this button, DataGrid1 must display only customer orders whose BackOrder value is set to True.
www.correctexams.com
- 32 -
Fast Way to get your Certification
How should you implement this functionality?
A.
B.
C.
D.
Set the RowFilter property of the DataView object to "BackOrder = True".
Set the RowStateFilter property of the DataView object to "BackOrder = True".
Set the Sort property of the DataView object to "BackOrder = True".
Set the ApplyDefaultSort property of the DataView object to True.
Answer: A
Explanation: Using the RowFilter property of a data view, you can filter records in a data table to make available only records you want to work with.
Reference:
Visual Basic and Visual C# Concepts, Introduction to Filtering and Sorting in Datasets
Visual Basic and Visual C# Concepts, Filtering and Sorting Data Using Data Views
Incorrect Answers
B: To filter based on a version or state of a record, set the RowStateFilter property. It does not apply here.
C, D: We want to filter, not sort the data view.
QUESTION NO: 34
You use Visual Studio .NET to create a Windows-based application called TestKingApp, that will be distributed to your customers. You add a setup project to your solution to create a distribution package. You deploy the distribution package on a test computer. However, you discover that the distribution package does not create a shortcut to your application on the Programs menu of the test computer.
You need to modify your setup project to ensure that this shortcut will be available on your customers
Programs menus.
What should you do?
A. Navigate to the User’s Programs Menu folder in the File System on Target Machine hierarchy.
Add the primary output from your application.
B. Navigate to the Application Folder folder in the File System on Target Machine hierarchy.
Create a shortcut to your application and move the shortcut to the User’s Programs Menu folder in the same hierarchy.
C. Navigate to the Install folder in the Customer Actions hierarchy.
Create a custom action that adds the primary output from your application to the User’s Programs
Menu folder.
D. Navigate to the Install folder in the Custom Actions hierarchy.
Create a custom action that adds a shortcut to your application’s executable file to the User’s
Programs Menu folder.
Answer: A
Explanation: We use the File System Editor to create a shortcut to the Application in the Programs Menu folder in the File System on Target Machine hierarchy.
www.correctexams.com
- 33 -
Fast Way to get your Certification
Note: The File System Editor is used to add project outputs and other files to a deployment project, to specify the locations where files will be installed on a target computer, and to create shortcuts on a target computer. Reference:
Visual Studio, File System Editor
Visual Studio, Adding and Removing Custom Actions in the Custom Actions Editor
Incorrect Answers
B: We want to add a shortcut to the Programs Menu, not to add a shortcut in the Application Folder.
C, D: The Custom Actions Editor is used to specify custom actions to be run during installation on a target computer. It is not used to create shortcuts for the Application.
QUESTION NO: 35
As a programmer at TestKing inc, you use Visual Studio .NET to create several applications that will be deployed commercially over the Internet. You must ensure that customers can verify the authenticity of your software.
Which action or actions should you take? (Choose all that apply.)
A.
B.
C.
D.
E.
Sign your portable executables by using Signcode.exe.
Generate an X.509 certificate by using Makecert.exe.
Purchase an X.509 certificate from a certificate authority.
Purchase a Software Publisher Certificate from a certificate authority.
Convert your certificate to a Software Publisher Certificate by using Cert2spc.exe.
Answer: A, D
Explanation:
D: We must use a Software Publisher Certificate from a certificate authority.
A: We then use this certificate to sign the portable executables with the Signcode.exe utility.
Reference:
Visual Basic and Visual C# Concepts, Code Security and Signing in Components
.NET Framework Tools, File Signing Tool (Signcode.exe)
.NET Framework Tools, Certificate Creation Tool (Makecert.exe)
Windows Storage System Technical Articles, Microsoft Windows 2000 Public Key Infrastructure
.NET Framework Tools, Software Publisher Certificate Test Tool (Cert2spc.exe)
Incorrect Answers
B: The Certificate Creation tool generates X.509 certificates for testing purposes only.
C: We should use a Software Publisher Certificate, not a X.509 certificate.
E: The Software Publisher Certificate Test tool creates a Software Publisher's Certificate (SPC) from one or more X.509 certificates. Cert2spc.exe is for test purposes only.
www.correctexams.com
- 34 -
Fast Way to get your Certification
QUESTION NO: 36
You create a Visual Studio .NET setup project to distribute an application. You add a SQL script named TestKingDB.SQL. You must ensure that the SQL script is executed during the installation process. What should you do?
A. Add a custom action to your setup project.
Select TestKingDB.SQL as the source path.
B. Add a batch file to your setup project to execute TestKingDB.SQL.
Add a launch condition to the setup project.
Set the Condition property to the batch file.
C. Create a new Visual Studio .NET project that executes TestKingDB.SQL.
Include the new project with your setup project.
Add a custom action that launches the new project during installation.
D. Add a launch condition to your setup project.
Set the Condition property to TestKingDB.SQL.
Answer: A
Explanation: By adding the SQL script as a custom action to the setup project we ensures that it will be executed during the installation process.
Note: Although standard actions are sufficient to execute an installation in most cases, custom actions enable the author of an installation package to extend the capabilities of standard actions by including executables, dynamic-link libraries, and script.
Reference: Platform SDK: Windows Installer, About Custom Actions
Incorrect Answers
B, D: The execution of a batch file cannot be used as a launch condition.
C: This is a very awkward solution. We don’t need to create a second project.
QUESTION NO: 37
You develop an application TestKingApp that will be sold commercially. You create a Visual Studio
.NET setup project to distribute the application. You must ensure that each user accepts your license agreement before installation occurs.
What should you do?
A. Add a launch condition to your setup project.
Add your license agreement to the Message property of the launch condition.
B. Open the user interface designer for your setup project.
Select the Welcome dialog box from the Start object and add your license agreement to the
CopyrightWarning property.
www.correctexams.com
- 35 -
Fast Way to get your Certification
C. Save you license agreement in the Rich Text Format and add the file to your setup project.
Open the property pages for the setup project and set the Certificate to the name of your Rich Text file. D. Save your license agreement in Rich Text Format and add the file to your setup project.
Open the user interface designer for the setup object.
From the Start object, select the License Agreement dialog box and set the LicenseFile property to the name of your Rich Text file.
Answer: D
Explanation: First we save the License agreement text in a RFT file and add it to the project. Then we use the User Interface Editor/Designer to configure the License Agreement dialog box.
Note: Visual Studio .NET provides a number of predefined user interface dialog boxes that can be displayed during installation to present or gather information. The dialog boxes to be displayed are specified in the
User Interface Editor.
Reference: Visual Studio. Deployment and the Run-Time User Interface
Incorrect Answers
A: Deployment dialog boxes are not configured with launch conditions.
B: The Welcome dialog box is not used for license agreements. Furthermore, we must create a RFT file containing the licensing agreement text.
C: The User Interface Editor must be used. We cannot configure the dialog box with the property pages of the project.
QUESTION NO: 38
You use Visual Studio .NET to create an assembly, called TestKingAssembly, that will be used by other applications, including a standard COM client application.
You must deploy your assembly on the COM application to a client computer. You must ensure that the COM application can instantiate components within the assembly as COM components.
What should you do?
A. Create a strong name of the assembly by using the Strong Name tool (Sn.exe).
B. Generate a registry file for the assembly by using the Assembly Registration tool (Regasm.exe)
Register the file on the client computer.
C. Generate a type library for the assembly by using the Type Library Importer (Tlbimp.exe).
Register the file on the client computer.
D. Deploy the assembly to the global assembly cache on the client computer.
Add a reference to the assembly in the COM client application.
Answer: B
Explanation: The Assembly Registration tool reads the metadata within an assembly and adds the necessary entries to the registry, which allows COM clients to create .NET Framework classes transparently. Once a class is registered, any COM client can use it as though the class were a COM class.
www.correctexams.com
- 36 -
Fast Way to get your Certification
Reference:
.NET Framework Tools, Assembly Registration Tool (Regasm.exe)
.NET Framework Tools, Strong Name Tool (Sn.exe)
.NET Framework Tools, Type Library Importer (Tlbimp.exe)
Incorrect Answers
A: The Strong Name tool helps sign assemblies with strong names.
C: The Type Library Importer, tlbimp.exe, converts the type definitions found within a COM type library into equivalent definitions in a common language runtime assembly. It would not be useful in this scenario however.
D: This would not allow the COM application to use the class.
QUESTION NO: 39
Another developer in your company uses Visual Studio .NET to create a component named
TestKiComponent. You deploy TestKiComponent to a server. When you execute TestKiComponent, you receive the following error message:
"System.Security.Policy.PolicyException: Failed to acquire required permissions."
As quickly as possible, you need to discover which permissions are required by TestKiComponent.
What should you do?
A. Request the source code from the developer who created My Component.
Examine the source code to find the required permissions.
B. Run the Microsoft CLR Debugger (DbgCLR.exe) on the server to view the permissions requested by the application at run time.
C. Run the Runtime Debugger (Cordbg.exe) on the server to view the permissions requested by the application at run time.
D. Run the Permissions View tool (Permview.exe) on the server to view the permissions required by
TestKiComponent.
E. Run the MSIL Disassembler (IIdasm.exe) on the server to view permissions requested by
TestKiComponent that were denied.
Answer: D
Explanation: Developers can use Permview.exe to verify that they have applied permission requests correctly to their code. Additionally, users can run Permview.exe to determine the permissions an assembly requires to execute.
Reference: .NET Framework Tools, Permissions View Tool (Permview.exe)
QUESTION NO: 40
www.correctexams.com
- 37 -
Fast Way to get your Certification
You develop an enterprise application, called TestKingApplication that includes a Windows Form presentation layer, middle-tier components for business logic and data access, and a Microsoft SQL
Server database.
You are in the process of creating a middle-tier component that will execute the data access routines in your application. When data is passed to this component, the component will call several SQL
Server stored procedures to perform database updates. All of these procedure calls run under the control of a single transaction.
The code for the middle-tier component will implement the following objects:
SqlConnection cn = new SqlConnection();
SqlTransaction tr;
If two users try to update the same data concurrently, inconsistencies such as phantom reads will occur. You must now add code to your component to specify the highest possible level of protection against such inconsistencies.
Which code segment should you use?
A.
B.
C.
D.
tr tr tr tr =
=
=
=
cn.BeginTransaction(“ReadCommitted”); cn.BeginTransaction(IsolationLevel.ReadCommitted); cn.BeginTransaction(IsolationLevel.Serializable); cn.BeginTransaction(“Serializable”); Answer: C
Explanation: Serializable is the highest isolation transaction level. It provide the highest possible level of protection against concurrent data errors. The correct syntax to begin a transaction with this transaction isolation level is: cn.BeginTransaction(IsolationLevel.Serializable)
Reference:
.NET Framework Class Library, SqlConnection.BeginTransaction Method (IsolationLevel) [C#]
.NET Framework Class Library, IsolationLevel Enumeration [C#]
Incorrect Answers
A: Incorrect syntax.
B: The ReadCommitted transaction isolation level can result in in non-repeatable reads or phantom data. It does not give the highest possible protection from parallel updates.
D: Incorrect syntax.
QUESTION NO: 41
You develop a Windows-based application, called TestKingSoftware that uses a Microsoft SQL
Server database to store and retrieve data. You decide to create a central error-handling procedure that processes all data errors that occur in TestKingSoftware. You must ensure that your application displays all error information that is received from the database.
www.correctexams.com
- 38 -
Fast Way to get your Certification
How should you write the error-handling procedure?
A. public void DisplaySqlErrors(SqlException myEx) {
MessageBox.Show(“Error: “ + myEx.ToString());
}
B. public void DisplaySqlErrors(SqlException myEx) {
MessageBox.Show(“Error: “ + myEx.Message);
}
C. public void DisplaySqlErrors(SqlException myEx) { foreach(SqlError x in myEx.Errors) {
MessageBox.Show(“Error: “ + x.ToString());
}
}
D. public void DisplaySqlErrors(SqlException myEx) { foreach(Exception x in myEx.Errors) {
MessageBox.Show(“Error: “ + x.ToString());
}
}
Answer: C
Explanation: The SQLException class represents the exception that is thrown when SQL Server returns a warning or error. We must the Errors member of SQLException class to retrieve a collection of one or more SqlError objects that give detailed information about exceptions generated by the SQL Server .NET
Data Provider.
Reference:
.NET Framework Class Library, SqlException Class [C#]
.NET Framework Class Library, SqlException Members
Incorrect Answers
A: We must the Errors member of SQLException class. We cannot simply apply the ToString method.
B: The Message member of the SQLException class gets the text describing the error. We want to display all error information so the Message member is inadequate for this scenario.
D: The Errors of the SQLException class gets a collection of SQLError objects, not Exception objects.
QUESTION NO: 42
As a developer at TestKing you develop a new sales analysis application that reuses existing data access components. One of these components returns a DataSet object that contains the data for all customer orders for the previous year.
You want your application to display orders for individual product numbers. Users will specify the appropriate product numbers at run time.
www.correctexams.com
- 39 -
Fast Way to get your Certification
What should you do?
A.
B.
C.
D.
Use the DataSet.Reset method.
Set the RowFilter property of the DataSet object by using a filter expression.
Create a DataView object and set the RowFilter property by using a filter expression.
Create a DataView object and set the RowStateFilter property by using a filter expression.
Answer: C
Explanation: You filter data by setting the RowFilter property. The RowFilter property takes a String that can evaluate to an expression to be used for selecting records. RowFilter is a property of the DataView object. Reference: Visual Basic and Visual C# Concepts, Filtering and Sorting Data Using Data Views
Incorrect Answers
A: The DataSet-Reset method resets the DataSet to its original state.
B: RowFilter is not a property of the DataSet object.
D: The RowStateFilter property is used to filter based on a version or state of a record. Filter expressions cannot be used on RowStateFilters. The RowStates are Added, CurrentRows, Deleted, ModifiedCurrent,
ModifiedOriginal, None, OriginalRows, and Unchanged.
QUESTION NO: 43
You develop a Windows-based application to manage business contacts. The application retrieves a list of contacts from a central database called TestKingDB. The list of contacts is managed locally in a
DataSet object named contactDataSet.
To set the criteria for retrieval, your user interface must enable users to type a city name into a
TextBox control.
The list of contacts that match this name must then be displayed in a DataGrid control.
Which code segment should you use?
A. DataView contactDataSet = new DataView(); dv.Table = contactDataSet.Tables[0]; dv.RowFilter = TextBox1.Text;
DataGrid1.DataSource = dv;
B. DataView dv = new DataView(); dv.Table = contactDataSet.Tables[0]; dv.RowFilter =
String.Format(“City = ‘{0}’”, TextBox1.Text);
DataGrid1.DataSource = dv;
C. DataView contactDataSet = new DataView(); dv.Table = contactDataSet.Tables[0]; dv.Sort = TextBox1.Text;
DataGrid1.DataSource = dv;
www.correctexams.com www.correctexams.com - 40 -
Fast Way to get your Certification
D. DataView dv = new DataView(); dv.Table = contactDataSet.Tables[0]; dv.Sort =
String.Format(“City = ‘{0}’”, TextBox1.Text);
DataGrid1.DataSource = dv;
Answer: B
Explanation: To form a RowFilter value, specify the name of a column followed by an operator and a value to filter on. The value must be in quotes. Here we use construct the rowfilter with the = operator, string concatenation (&) and the TextBox1.Text property.
Reference: .NET Framework Class Library, DataView.RowFilter Property [C#]
Incorrect Answers
A: We must use the = operator and construct an expression. We cannot just use a value.
C, D:
We want to filter the Dataset, not to sort it.
QUESTION NO: 44
You develop a Windows-based application TestK. TestK uses a DataSet object that contains two
DataTable objects. TestK will display data from two data tables. One table contains customer information, which must be displayed in a data-bound ListBox control. The other table contains order information, which must be displayed in a DataGrid control.
You need to modify TestK to enable the list box functionality.
What should you do?
A.
B.
C.
D.
Use the DataSet.Merge method.
Define primary keys for the Data Table objects.
Create a foreign key constraint on the DataSet object.
Add a DataRelation object to the Relations collection of the DataSet object.
Answer: D
Explanation: We want to use data from both DataTable object. We must relate the DataTable objects.
A DataRelation is used to relate two DataTable objects to each other through DataColumn objects.
DataRelation objects are contained in a DataRelationCollection, which you can access through the Relations property of the DataSet.
Reference:
.NET Framework Class Library, DataRelation Class [C#]
.NET Framework Class Library, DataSet.Merge Method (DataSet) [C#]
.NET Framework Class Library, ForeignKeyConstraint Class [C#]
Incorrect Answers
www.correctexams.com
- 41 -
Fast Way to get your Certification
A: The Merge method is used to merge two DataSet objects that have largely similar schemas. In this scenario we want combine the information from the DataTable objects, not merge them
B: Creating a primary key for each Data Table object would not relate the DataTable objects.
C: We should use a Datarelation, not a foreign key constraint, to relate the DataTable objects.
Note: A foreign key constraint represents an action restriction enforced on a set of columns in a primary key/foreign key relationship when a value or row is either deleted or updated.
QUESTION NO: 45
You develop an application that enables users to enter and edit purchase order details. The application includes a Windows Form named DisplayTestKingForm. The application uses a clientside DataSet object to manage data.
The DataSet object contains a Data Table object named TestKingDetails. This object includes one column named Quantity and another named UnitPrice. For each item on a purchase order, your application must display a line item total in a DataGrid control on DisplayTestKingForm. The line item is the product of Quantity times UnitPrice. Your database design does not allow you to store calculated values in the database.
You need to add code to your Form_Load procedure to calculate and display the line item total.
Which code segment should you use?
A. DataColumn totalColumn = new DataColumn(“Total”,Type.GetType(“System.Decimal”));
TestKingDetails.Columns.Add(totalColumn;
totalColumn.Expression = “Quantity * UnitPrice”;
B. DataColumn totalColumn =
NewDataColumn(“Total”, Type.GetType(“System.Decimal”));
TestKingDetails.Columns.Add(totalColumn;
TotalColumn.Equals(“Quantity * UnitPrice”);
C. TestKingDetails.DisplayExpression(“Quantity * UnitPrice”;
D. TestKingDetails.DisplayExpression(“quantityColumn * unitPriceColumn”);
Answer: A
Explanation: We use the Expression property of the DataColumn object calculate the values in the column. Reference:
.NET Framework Developer's Guide, Creating Expression Columns [C#]
.NET Framework Class Library, DataColumn Class [C#]
.NET Framework Class Library, Object.Equals Method (Object) [C#]
.NET Framework Class Library, DataTable.DisplayExpression Property [C#]
Incorrect Answers
B: The Equals method cannot be used in this way. The equals method is used to test if different objects are equal. C, D: The DisplayedExpression would be set to a string value, not a calculated value.
www.correctexams.com www.correctexams.com - 42 -
Fast Way to get your Certification
QUESTION NO: 46
You develop an inventory management application called TestKingManagement that will call a
Microsoft SQL Server stored procedure named sp_GetDailyTestKingSales. The stored procedure will run a query that returns your daily sales total as an output parameter.
This total will be displayed to users in a message box.
Your application uses a SqlCommand object to run sp_GetDailyTestKingSales. You write the following code to call sp_GetDailyTestKingSales:
SqlConnection cnn = new SqlConnection(myConnString);
SqlCommand cmd = new SqlCommand(“sp_GetDailyTestKingSales”, cnn); cmd.CommandType = CommandType.StoredProcedure;
SqlParameter prm = cmd.Parameters.Add(“@ItemTotal”,
SqlDbType.Int);
prm.Direction = ParameterDirection.Output; cnn.Open(); cmd.ExecuteNonQuery();
Now you must write additional code to access the output parameter. Which code segment should you use? A. MessageBox.Show(“Total is: “ + cmd.Parameters[“@Output”].Value.ToString()); B. MessageBox.Show(Total is: “ + cmd.Parameters[“@Output”].ToString()); C. MessageBox.Show(“Total is: “ + cmd.Parameters[“@ItemTotal”].ToString()); D. MessageBox.Show(“Total is: “ + cmd.Parameters[“@ItemTotal”].ToString()); Answer: C
Explanation: The @ItemTotal parameter is declared as an output parameter with SQL Server data type
INT. We use the Value property of the SQLParameter class to retrieve the value of this parameter. We must also convert the INT value to a string value with the ToString method. We then supply this string to the
MessageBox.Show method.
Reference:
.NET Framework Class Library, SqlParameter Class [C#]
.NET Framework Class Library, SqlParameter.Direction Property [C#]
.NET Framework Class Library, SqlParameter.SqlDbType Property [C#]
.NET Framework Class Library, SqlParameter.Value Property [C#]
Incorrect Answers
A, B: The @ItemTotal parameter is the output parameter. Using @Output this way is incorrect. Output is a keyword and no variable named @Output has been declared.
www.correctexams.com
- 43 -
Fast Way to get your Certification
D: We must use the Value method to retrieve the value of the parameter.
QUESTION NO: 47
You develop a Windows-based application. The application uses a DataSet object that contains two
DataTable objects. The application will display data from the two data tables. One table contains customer information, which must be displayed in a data-bound ListBox control. The other table contains order information, which must be displayed in a DataGrid control.
You need to modify your application to enable the list box functionality. What should you do?
A.
B.
C.
D.
Use the DataSet.Merge method.
Define primary keys for the DataTable objects.
Create a foreign key constraint on the DataSet object.
Add a DataRelation object to the Relation collection of the DataSet object.
Answer: D
Explanation: You can use a DataRelation to retrieve parent and child rows. Related rows are retrieved by calling the GetChildRows or GetParentRow methods of a DataRow.
Note: A DataRelation object represents a relationship between two columns of data in different tables. The
DataRelation objects of a particular DataSet are contained in the Relations property of the DataSet. A
DataRelation is created by specifying the name of the DataRelation, the parent column, and the child column. Reference: 70-306/70-316 Training kit, Retrieving Related Records, Page 286
Incorrect Answers
A: The Merge method is used to merge two DataSet objects that have largely similar schemas. A merge does not meet the requirements of the scenario however.
B: Primary keys would not help relating the DateTable objects.
C: Foreign key constraints put restrictions on the data in two different tables. However, it would not help in retrieving related records.
QUESTION NO: 48
You plan to develop a customer information application CustomTK that uses a Microsoft SQL Server database. CustomTK will be used frequently by a large number of users. Your application code must obtain the fastest possible performance when accessing the database and retrieving large amounts of data. You must accomplish this goal with the minimum amount of code.
How should you design CustomTK?
A. Use classes in the System.Data.OleDb namespace.
B. Use classes in the System.Data.SqlClient namespace.
www.correctexams.com www.correctexams.com - 44 -
Fast Way to get your Certification
C. Use remoting to connect to the SQL Server computer.
D. Use interoperability to include legacy COM-based data access components.
Answer: B
Explanation: The System.Data.SqlClient namespace is the SQL Server .NET Data Provider. It gives the best performance for accessing the Microsoft SQL Server database.
Reference:
.NET Framework Class Library, System.Data.SqlClient Namespace
.NET Framework Class Library, System.Data.OleDb Namespace
.NET Framework Developer's Guide, .NET Remoting Overview
Incorrect Answers
A: The System.Data.OleDb namespace is the OLE DB .NET Data Provider.
C: Microsoft .NET Remoting technology provides a framework for distributing objects across different process boundaries and machine boundaries. It would not the fastest solution.
D: Legacy COM-based data access components would not be optimal for performance.
QUESTION NO: 49
You develop a Windows-based application that connects to a Microsoft SQL Server database. Errors sometimes occur when users execute stored procedures in the database. You need to add errorhandling code to your application to capture detailed information about any stored procedure that causes an error.
Which code segment should you use?
A. try {
TestKingConnection.Open();
} catch (Exception e) {
// Insert error-handling code.
}
B. try {
TestKingConnection.Open();
} catch (SqlException e) {
// Insert error-handling code.
}
C. try {
TestKingConnection.Open();
} catch (DataException e) {
// Insert error-handling code.
}
D. try {
www.correctexams.com
- 45 -
Fast Way to get your Certification
TestKingConnection.Open();
} catch (DBConcurrencyException e) {
// Insert error-handling code.
}
Answer: B
Explanation: SqlException Class implements the exception that is thrown when SQL Server returns a warning or error.
Reference: .NET Framework Class Library, SqlException Class [C#]
QUESTION NO: 50
You execute a query on your external Oracle database named TestKingSalesDate by using an
OleDbCommand object. The query uses the Average function to return a single value that represents the average price of products in the inventory table. You want to optimize performance when you execute this query.
To execute this query from your ADO.NET code, you need to use a method of the OleDbCommand object. Which method should you use?
A.
B.
C.
D.
ExecuteNonQuery
ExecuteScalar
ToString
ExecuteReader
Answer: B
Explanation: The ExecuteScalar method returns the first column of the first row of data returned by the command, no matter how many rows the command actually selects.
Reference: 70-306/70-316 Training kit, The Command Object, Pages 252-253
Incorrect Answers
A: .The ExecuteNonQuery method executes the data command, but returns no value.
C: The command object has no ToString method.
D: The ExecuteReader method returns a DataReader object that can iterate through a result set in a forwardonly, read-only manner without involving a DataAdapter.
QUESTION NO: 51
www.correctexams.com
- 46 -
Fast Way to get your Certification
You develop a Windows-based application that creates XML output from a DataSet object. The XML output is created by using the DataSet.WriteXml method and then is sent to another application. The second application requires the output to appear in the following format:
You need to write code to specify the format for the XML output. Which code segment should you use? A. ds.WriteXml(dataFile,
XmlWriteMode.WriteSchema);
B. ds.WriteXml(dataFile,
XmlWriteMode.IgnoreSchema);
C. foreach (DataColumn dc in ds.Tables[“employee”].Columns) { dc.ColumnMapping = MappingType.Attribute;
}
D. foreach (DataColumn dc in ds.Tables[“employee”].Columns) { dc.ColumnMapping = MappingType.Element;
}
Answer: C
Explanation: We want to produce an attribute list with no tags.
The WriteSchema XmlWriteMode writes the current contents of the DataSet as XML data with the relational structure as inline XML Schema as is required in this scenario.
Reference:
.NET Framework Class Library, MappingType Enumeration
.NET Framework Developer's Guide, Writing a DataSet as XML Data [C#]
NET Framework Class Library. DataSet.WriteXml Method [C#]
QUESTION NO: 52
You develop a Windows-based application called TestKingApplication by using Visual Studio .NET.
TestKingApplication receives XML data files from various external suppliers. An XML Schema file defines the format and the data types for the XML data files.
TestKingApplication must parse the incoming XML data files to ensure that they conform to the schema. What should you do?
A.
B.
C.
D.
Implement a DataSet object and code an event handler to process its events.
Implement a DataSet object and set its Enforce Constraints property to True.
Implement an XmlValidatingReader object and code an event handler to process its events.
Implement an XmlValidatingReader object and examine its ReadState property after reading the
XML data file.
Answer: C
www.correctexams.com www.correctexams.com - 47 -
Fast Way to get your Certification
Explanation: The XmlValidatingReader class, an implementation of the XmlReader class, provides support for XML validation. The ValidationEventHandler event is used to set an event handler for receiving information about schema validation errors.
Reference:
.NET Framework Developer's Guide, Validation of XML with XmlValidatingReader
.NET Framework Developer's Guide, XmlValidatingReader Validation Event Handler Callback [C#]
QUESTION NO: 53
You develop a Windows-based application that interacts with a Microsoft SQL Server database. The application inserts new rows into the database by calling the following stored procedure. (Line numbers are included for reference only)
01
02
03
04
05
06
07
08
ALTER PROCEDURE dbo.sp_UpdateTestKingPrice
(
@category int,
@totalprice money OUTPUT
)
AS
SET NOCOUNT ON
UPDATE Products SET UnitPrice = UnitPrice * 1.1
WHERE CategoryID = @category
09 SELECT @totalprice = sum(UnitPrice) FROM Products
10 SELECT ProductName FROM Products
WHERE CategoryID = @category
11 RETURN @Totalprice
You application uses the ExecuteReader method of the SqlCommand object to call the stored procedure and create a SqlDataReader object. After the stored procedure runts, your code must examine the SqlDataReader.RecordsAffected property to verify that the correct number of records is successfully updated.
However, when you execute the stored procedure, the SqlDataReader.RecordsAffected property always returns –1. How should you correct this problem?
A. Change line 7 to
SET ROWCOUNT 0
B. Change line 7 to
SET NOCOUNT OFF
C. Change line 11 to
RETURN 0
D. Change line 11 to
RETURN @category
Answer: B
www.correctexams.com
- 48 -
Fast Way to get your Certification
Explanation: SqlDataReader.RecordsAffected Property gets the number of rows changed, inserted, or deleted by execution of the Transact-SQL statement.
The Transact-SQL SET NOCOUNT command stops the message indicating the number of rows affected by a Transact-SQL statement from being returned as part of the results. When SET NOCOUNT is ON, the count (indicating the number of rows affected by a Transact-SQL statement) is not returned. When SET
NOCOUNT is OFF, the count is returned.
Reference:
SQL Server Books Online, SET NOCOUNT
.NET Framework Class Library, SqlDataReader.RecordsAffected Property [Visual Basic]
Incorrect Answers
A: The SET NOCOUNT 0 is incorrect. We should use OFF instead of =.
C, D: We cannot change the functionality of the stored procedure by changing the RETURN statement.
Furthermore, returning = or the value of @Category value does not achieve the desired result.
QUESTION NO: 54
You use Visual Studio .NET to develop a Microsoft Windows-based application. Your application contains a form named CustomerForm, which includes the following design-time controls:
•
•
•
•
•
SQLConnection object named TestKingConnection
SQLDataAdapter object named TestKingDataAdapter
DataSet object named CustomerDataSet
Five TextBox controls to hold the values exposed by CustomerDataSet
Button control named saveButton
At design time you set the DataBindings properties of each TextBox control to the appropriate column in the DataTable object of CustomerDataSet.
When the application runs, users must be able to edit the information displayed in the text boxes. All user changes must be saved to the appropriate database when saveButton is executed. The event handler for saveButton includes the following code segment:
NorthwindDataAdapter.Update(CustomerDataSet);
You test the application. However, saveButton fails to save any values edited in the text boxes.
You need to correct this problem.
What should your application do?
A.
B.
C.
D.
Call the InsertCommand method of TestKingDataAdapter.
CALL THE Update method of TestKingDataAdapter and pass in TestKingConnection.
Before calling the Update method, ensure that a row position change occurs in CustomerDataSet.
Reestablish the database connection by calling the Open method of TestKingConnection.
Answer: B
www.correctexams.com
- 49 -
Fast Way to get your Certification
Explanation: We must specify the Data Source as well. The Data Source is specified with the
SQLConnection object. We should issue the following command:
TestKingDataAdapter.Update(CustomerDataSet, TestKingConnection);
Reference:
Visual Basic and Visual C# Concepts, Dataset Updates in Visual Studio .NET
.NET Framework Class Library, SqlDataAdapter Constructor (String, SqlConnection) [C#]
QUESTION NO: 55
You use Visual Studio .NET to develop a Windows-based application. Your application includes a form named TestKingInformationForm, which enables users to edit information stored in a database.
All user changes to this information must be saved in the database.
You need to write code that will prevent TestKingInformationForm from closing if any database changes are left unsaved. What should you do?
A.
B.
C.
D.
Include this.Activate in the Closing event handler of TestKingInformationForm.
Include this.Activate in the Closed event handler of TestKingInformationForm.
Include this.Activate in the Leave event handler of TestKingInformationForm.
Change a property of the System.ComponentModel.CancelEventArgs parameter in the Closing event handler of TestKingInformationForm.
E. Change a property of the System.EventArgs parameter in the Closed event handler of
TestKingInformationForm.
F. Change a property of the System.EventArgs parameter in the Leave event handler of
TestKingInformationForm.
Answer: D
Explanation: The CancelEventArgs Class Provides data for a cancelable event. A cancelable event is raised by a component when it is about to perform an action that can be canceled, such as the Closing event of a
Form.
Reference:
NET Framework Class Library, CancelEventArgs Class [C#]
Visual Studio, Activate Method (General Extensibility) [C#]
Incorrect Answers
A: A closing event of a form cannot be cancelled with a this.activate statement.
B: It is too late when the Closed event occurs.
C: A form is not closing, just losing focus, when the Leave event occurs.
E: It is too late when the Closed event occurs.
F: A form is not closing, just losing focus, when the Leave event occurs.
www.correctexams.com www.correctexams.com - 50 -
Fast Way to get your Certification
QUESTION NO: 56
As a software developer at TestKing inc. you use Visual Studio .NET to create a Windows-based application. You need to make the application accessible to users who have low vision. These users navigate the interface by using a screen reader, which translates information about the controls on the screen into spoken words. The screen reader must be able to identify which control currently has focus. One of the TextBox controls in your application enables users to enter their names. You must ensure that the screen reader identifies this TextBox control by speaking the word "name" when a user changes focus to this control.
Which property of this control should you configure?
A.
B.
C.
D.
E.
Tag
Next
Name
AccessibleName
AccessibleRole
Answer: D
Explanation: The AccessibleName property is the name that will be reported to the accessibility aids.
Reference:
Visual Basic and Visual C# Concepts, Providing Accessibility Information for Controls on a Windows Form
Visual Basic and Visual C# Concepts, Walkthrough: Creating an Accessible Windows Application
Incorrect Answers
A, B, C: The Tag, Next and Name properties of a control is not used directly by accessibility aids.
E: The AccessibleRole property describes the use of the element in the user interface.
QUESTION NO: 57
You use Visual Studio .NET to develop an application for users the intranet of your company
TestKing. All client computers use Internet Explorer as their Web browser. You plan to create a setup package to distribute your application.
The setup package must fulfill the following requirements:
•
•
•
It is placed in a network folder that is accessible to users.
It is accessible through a link on your company's intranet.
It includes an uninstaller for the application.
Which type of project should you create?
A.
B.
C.
D.
CAB project. merge module project. setup project.
Web setup project.
www.correctexams.com
- 51 -
Fast Way to get your Certification
Answer: D
Explanation: To deploy a Web application to a Web server, you create a Web Setup project, build it, copy it to the Web server computer, and run the installer to install the application on the server using the settings defined in your Web Setup project.
Reference:
Visual Studio, Deployment of a Web Setup Project
Visual Studio, CAB File Projects
Visual Studio, Adding Merge Modules to a Deployment Project
Visual Studio, Setup Projects
Incorrect Answers
A: CAB projects allow you to create a .cab file to package ActiveX controls, not applications however, that can be downloaded from a Web server to a Web browser.
B: You don't install merge module projects with Internet Explorer.
Note: Merge modules (.msm files) allow you to share components between multiple deployment projects. C: You don't install setup projects with Internet Explorer.
Note: Setup projects allow you to create installers in order to distribute an application. The resulting
Windows Installer (.msi) file contains the application, any dependent files, information about the application such as registry entries, and instructions for installation.
QUESTION NO: 58
You use Visual Studio .NET to create an application that will be distributed to employees within your company TestKing Inc. You create and deploy a distribution package to test a computer running
Windows 2000 Professional.
Later you discover that your name is listed as the support contact for your application by the
Add/Remove Programs option of Control Panel. You need to change the support contact to the name of your Help desk administrator.
Which property of the setup project should you change?
A.
B.
C.
D.
Author
Comments
Manufacturer
SupportPhone
Answer: A
Explanation: The Author property specifies the name of the author of an application or component. Once the application is installed, the property is also displayed in the Contact field of the Support Info dialog box.
Reference:
Visual Studio, Deployment Properties
Visual Studio, Author Property
www.correctexams.com www.correctexams.com - 52 -
Fast Way to get your Certification
Visual Studio, Manufacturer Property
Incorrect Answers
B: There is no Deployment property called comments.
C: The Manufacturer property specifies the name of the manufacturer of an application or component, usually the name of the company that developed it. Once the application is installed, the Manufacturer property is displayed in the Publisher field of the Support Info dialog box.
D: We are not interested in supplying a telephone number-
QUESTION NO: 59
You develop a Windows-based application called TestKingSecurity by using Visual Studio .NET and
Microsoft SQL Server. The application will perform numerous Assert, Deny, and PermitOnly security operations while it is executing. You must ensure that the application is optimized for fast run-time execution. What should you do?
A.
B.
C.
D.
Perform declarative security checks.
Perform imperative security checks.
Perform all security checks by using SQL Server security.
Implement a custom security class that retrieves security information from the SQL Server database.
Answer: A
Explanation: Declarative security checks in the application would be the fastest solution.
Reference:
.NET Framework Developer's Guide, Performing Declarative Security Checks [Visual Basic]
.NET Framework Developer's Guide , Adding Declarative Security Support [Visual Basic]
Visual Basic and Visual C# Concepts, Adding Imperative Security Checks to Components
Incorrect Answers
A: Imperative security checks allow you to protect specific blocks of code by requiring appropriate permissions. It cannot be used for Assert, Deny, and PermitOnly security operations.
C, D: SQL Server security would be more scalable, but less optimized.
QUESTION NO: 60
You develop a Windows-based time and billing application named TestKingBilling. You create a simple user interface to capture user-entered data.
The application passes an Object array of user-entered values to a function named
AddUpDataTimeEntry. This function uses the LoadDataRow method of the Data Table object either to update an existing record in the table or to add a new record.
When you test TestKingBilling, you frequently receive an exception of type InvalidCastException.
What us the cause of this error?
www.correctexams.com
- 53 -
Fast Way to get your Certification
A. You are trying to load a duplicate value into a Data Table column that has a unique constraint.
B. The number of items in your Object array does not match the number of columns in the Data Table object. C. The data that you are trying to load into a column is not the correct data type specified for that column. D. The columns in your Data Table object do not have the AllowDBNull property set to True.
Answer: C
Explanation: InvalidCastException Class implements the exception that is thrown for invalid casting or explicit conversion. An InvalidCastException could be caused by an incorrect data type.
QUESTION NO: 61
You use Visual Studio .NET to create an assembly that will be consumed by other Visual Studio .NET applications. No Permissions should be granted to this assembly unless the assembly makes a minimum permission request for them.
Which code segment should you use?
A.
B.
C.
D.
Answer: C
Explanation: The RequestOptional SecurityAction requests for additional permissions that are optional
(not required to run). This action can only be used within the scope of the assembly. The assembly must have permission to request additional permission.
Reference:
.NET Framework Developer's Guide Requesting Optional Permissions [C#]
.NET Framework Class Library, SecurityAction Enumeration [C#]
Incorrect Answers:
A, B: The PermitOnly SecurityAction does not support Assembly as a target, it only supports Class or
Method as targets.
D: The assembly must be able to request additional permissions.
www.correctexams.com
- 54 -
Fast Way to get your Certification
QUESTION NO: 62
You use Visual Studio .NET to create a Windows-based application. The application captures screen shots of a small portion of the visible screen.
You create a form named TestKingCameraForm. You set the TestKingCameraForm.BackColor property to Blue. You create a button on the form to enable users to take a screen shot.
Now, you need to create a transparent portion of TestKingCameraForm to frame a small portion of the screen. Your application will capture an image of the screen inside the transparent area. The resulting appearance of TestKi ngCameraForm is shown in the exhibit:
You add a Panel control to TestKingCameraForm and name it transparentPanel. You must ensure that any underlying applications will be visible within the panel.
Which two actions should you take? (Each correct answer presents part of the solution. Choose two.)
A. Set transparentPanel.BackColor to Red.
B. Set transparentPanel.BackColor to Blue.
C. Set transparentPanel.BackgroundImage to None.
www.correctexams.com
- 55 -
Fast Way to get your Certification
D.
E.
F.
G.
Set transparentPanel.Visible to False.
Set CameraForm.Opacity to 0%.
Set CameraForm.TransparencyKey to Red.
Set CameraForm.TransparencyKey to Blue.
Answer: A, F
Explanation:
A: We set the Background color of the Panel to Red.
F: We then the transparency color of the Form to Red as well.
This will make only the Panel transparent, since the background color of the form is Blue.
QUESTION NO: 63
You develop a Windows-based application named TestKingPurchase that exchanges data with an accounting application. Purchase receives purchase order data from the accounting application in
XML format. Users of TestKingPurchase review and edit the data.
TestKingPurchase maintains the data in a DataSet object while users are working. When they are finished making changes, TestKingPurchase must create an output file that will be returned to the accounting application. For verification and auditing purposes, the accounting application must receive both the user changes and the original values.
Now you need to write code that will create the output file.
What should you do?
A.
B.
C.
D.
Call the DataSet.WriteXmlSchema method and specify a TextWriter object as the argument.
Call the DataSet.WriteXmlSchema method and specify an XmlWriter object as the argument.
Call the DataSet.WriteXml method and specify WriteSchema as the XmlWriteMode parameter.
Call the DataSet.WriteXml method and specify DiffGram as the XmlWriteMode parameter.
Answer: D
Explanation: A DiffGram is an XML format that is used to identify current and original versions of data elements. Here we use the DataSet.WriteXml method with the Diffgram XmlWriteMode to write the entire
DataSet as a DiffGram, including original and current values.
Reference:
.NET Framework Developer's Guide, DiffGrams
.NET Framework Developer's Guide, Writing a DataSet as XML Data [C#]
Incorrect Answers
A, B: We want to write the Dataset in XML format, not as an XML schema.
C: The WriteSchema XmlWriteMode writes only the current contents of the DataSet as XML data (with the relational structure as inline XML Schema).
www.correctexams.com www.correctexams.com - 56 -
Fast Way to get your Certification
QUESTION NO: 64
Your company TestKing, uses Visual Studio .NET to develop internal applications. You create a
Windows control that will display custom status bar information.
Many different developers at TestKing will use the control to display the same information in many different applications. The control must always be displayed at the bottom of the parent form in every application. It must always be as wide as the form. When the form is resized, the control should be resized and repositioned accordingly.
What should you do?
A. Create a property to allow the developers to set the Dock property of the control.
Set the default value of the property to AnchorStyle.Bottom.
B. Create a property to allow the developer to set the Anchor property of the control.
Set the default value of the property to AnchorStyle.Bottom.
C. Place the following code segment in the UserControl_Load event: this.Dock = DockStyle.Bottom
D. Place the following code segment in the UserControl_Load event: this.Anchor = AnchorStyle.Bottom
Answer: C
Explanation:
DockStyle.Bottom docks the control to the bottom of the form. This will force the control to be as wide as to form. Furthermore the control will be resized automatically.
Reference:
Visual Basic and Visual C# Concepts, Aligning Your Control to the Edges of Forms
NET Framework Class Library, AnchorStyles Enumeration [C#]
Incorrect Answers
A: There is no need to the other developers to set the Dock property.
B: The Dock property should be used.
D: The Anchorstyle class specifies how a control anchors to the edges of its container. Not how a control is docked. QUESTION NO: 65
Your development team is creating a new Windows-based application for the TestKing company. The application consists of a user interface and several XML Web services. You develop all XML Web services and perform unit testing. Now you are ready to write the user interface code.
Because some of your servers are being upgraded, the XML Web service that provides mortgage rates is currently offline. However, you have access to its description file.
You must begin writing code against this XML Web service immediately.
What should you do?
A. Generate the proxy class for the XML Web service by using Disco.exe.
B. Generate the proxy class for XML Web service by using Wsdl.exe.
www.correctexams.com
- 57 -
Fast Way to get your Certification
C. Obtain a copy of the XML Web service assembly and register it on your local development computer. D. Add the description file for the XML Web service to your Visual Studio .NET project.
Answer: B
Explanation:
Ordinarily to access an XML Web service from a client application, you first add a Web reference, which is a reference to an XML Web service. When you create a Web reference, Visual Studio creates an XML Web service proxy class automatically and adds it to your project.
However, you can manually generate a proxy class using the XML Web services Description Language
Tool, Wsdl.exe, used by Visual Studio to create a proxy class when adding a Web reference. This is necessary when you are unable to access the XML Web service from the machine on which Visual Studio is installed, such as when the XML Web service is located on a network that will not be accessible to the client until run time. You then manually add the file that the tool generated to your application project.
Reference:
Visual Basic and Visual C# Concepts, Locating XML Web Services
Visual Basic and Visual C# Concepts, Generating an XML Web Service Proxy
QUESTION NO: 66
You use Visual Studio .NET to create a Windows Form named TestKingForm. You add a custom control named BarGraph, which displays numerical data. You create a second custom control named
DataBar. Each instance of DataBar represents one data value in BarGraph.
BarGraph retrieves its data from a Microsoft SQL Server database. For each data value that it retrieves, a new instance of DataBar is added to BarGraph. BarGraph also includes a Label control named DataBarCount, which displays the number of DataBar controls currently contained by
BarGraph.
You must add code to one of your custom controls to ensure that DataBarCount is always updated with the correct value.
What are two possible ways to achieve this goal? (Each correct answer presents a complete solution.
Choose two)
A. Add the following code segment to the ControlAdded event handler for DataBar: this.DataBarCount.Text = this.Controls.Count;
B. Add the following code segment to the ControlAdded event handler for DataBar: this.DataBarCount.Text = Parent.Controls.Count;
C. Add the following code segment to the ControlAdded event handler for BarGraph:
DataBarCount.Text = this.Controls.Count;
D. Add the following code segment to the constructor for BarGraph: this.Parent.DataBarCount.Text = this.Controls.Count;
E. Add the following code segment to the constructor for DataBar: this.Parent.DataBarCount.Text = this.Controls.Count;
F. Add the following code segment to the AddDataPoint method of BarGraph:
DataBarCount.Text = this.Controls.Count;
www.correctexams.com
- 58 -
Fast Way to get your Certification
Answer: C, E
Explanation: We could either catch the ControlAdded event, or add code the constructor.
C: The Control.ControlAdded Event occurs when a new control is added to the Control.ControlCollection.
When a control is added to BarGraph we could set the count of controls to the number of current controls in BarGraph.
E: Every time a new DataBar is constructed we could set the counter.
Reference: .NET Framework Class Library, Control.ControlAdded Event [C#]
Incorrect Answers
A, B: Controls are added to BarGraph not to the DataBar.
D: DataBars, not BarGraphs, are constructed.
F: The AddDataPoint method does not apply.
QUESTION NO: 67
You develop a Windows-based application for tracking telephone calls. The application stores and retrieves data by using a Microsoft SQL Server database.
You will use the SQL Client managed provider to connect and send commands to the database. You use integrated security to authenticate users. Your server is called TestKing30 and the database name is CustomerService.
You need to set the connection string property of the SQL Connection object.
Which code segment should you use?
A. "Provider=SQLOLEDB.1;Data Source=TestKing30;
Initial Catalog=CustomerService"
B. "Provider=MSDASQL;Data Source= TestKing30;
Initial Catalog=CustomerService"
C. "Data Source= TestKing30;Initial Catalog=Master"
D. "Data Source= TestKing30;
Initial Catalog=CustomerService"
Answer: D
Explanation: We simply specify the name of the server as Data Source, and the name of database as Initial
Catalog.
Reference: .NET Framework Class Library, OleDbConnection.ConnectionString Property [C#]
Incorrect Answers
A: We are using SQL Client Object so we cannot use a Provider tag. We are not connecting to a MS SQL
Server database.
B: We are using SQL Client Object so we cannot use a Provider tag. Furthermore, the MSDASQL provider is used for Oracle databases, not for Microsoft SQL Server databases.
C: The database name is CustomerService, not Master.
www.correctexams.com
- 59 -
Fast Way to get your Certification
QUESTION NO: 68
You are maintaining a Visual Studio .NET application that was created by another developer. The application functions as expected for several months. Then users report that it sometimes calculates tax amounts incorrectly.
An examination of the source code leads you to suspect that the errors are caused by a function named CalculateTestKingSales. To test your hypothesis, you place a breakpoint on the following line of code: decTax = CalculateTestKingSales(decRate, decSaleAmount);
However, when you run the application to create a test invoice, the breakpoint is not invoked.
How should you correct this problem?
A. Select Enable All Breakpoints from the Debug menu.
B. Select Configuration Manager from the Build menu.
Set the Activate Solution Configuration option to Debug.
Set the Configuration property of the project to Debug.
C. Select Options from the Tools menu and then select the General object from the Debugging folder.
Choose the option In break mode, only stop execution of the current process.
D. Select Exceptions from the Debug menu.
Under the heading If the exception is not handles, select Break into the Debugger.
Answer: B
Explanation: If the Active Solution Configuration is set to Release, no Breakpoints would apply. This could cause the behavior described in this scenario. If we should change this setting to Debug the breakpoints would be applied.
Reference:
Visual Studio, Configuration Manager Dialog Box
Visual Studio, Exceptions Dialog Box
Incorrect Answers
A: There is no Enable All Breakpoints command on the Debug menu.
C: The is no option In break mode, only stop execution of the current process, or any other debugging configuration, in the General options.
D: We are not interested in exceptions. We just want to breakpoints to apply.
QUESTION NO: 69
You develop a Windows-based application named TestKing3 by using Visual Studio .NET. TestKing3 consumes an XML Web service named MortgageRate and exposes a method named GetCurrentRate.
TestKing3 uses GetCurrentRate to obtain the current mortgage interest rate.
www.correctexams.com
- 60 -
Fast Way to get your Certification
Six months after you deploy TestKing3, users begin reporting errors. You discover that
MortgageRate has been modified. GetCurrentRate now requires you to pass a postal code before returning the current mortgage interest rate.
You must ensure that TestKing3 consumes the most recent version of MortgageRate. You must achieve this goal in the most direct way possible.
What should you do?
A.
B.
C.
D.
E.
Use Disco.exe to generate a new proxy class for MortgageRate.
Modify the TestKing3 code to pass the postal code to GetCurrentRate.
Use the Update Web Reference menu item to update the reference to MortgageRate in TestKing3.
Use the Add Reference dialog box to recreate the reference to MortgageRate in TestKing3.
Remove the reference to MortgageRate in TestKing3. Use the Add Web Reference dialog box to create the reference.
Answer: C
Explanation: If your application contains a Web reference to an XML Web service that has been recently modified on the server, you may need to update the reference in your project.
To update a project Web reference
1. In Solution Explorer, access your project's Web References folder and select the node for the Web reference you want to update.
2. Right-click the reference and click Update Web Reference.
Reference: Visual Basic and Visual C# Concepts, Managing Project Web References
QUESTION NO: 70
Your development team is creating a Windows-based application for the TestKing company. The application asynchronously calls the ProcessLoan method of an XML Web service. The XML Web service will notify your code when it finished executing ProcessLoan.
You must ensure that your code can continue processing while waiting for a response from the XML
Web service. Your code must establish when ProcessLoan finished executing.
What should your application do?
A. Use the WaitHande.WaitAny method of the IAsyncResult.AsyncWaitHandle object.
Examine the value of IAsyncResult.IsCompleted to see if ProcessLoan is finished executing.
B. Use the WaitHandle.WaitAll method of the IAsyncResult.AsyncWaitHandle object.
Examine the value of IAsyncResult.IsCompleted to see of ProcessLoan is finished executing.
C. Supply a callback delegate to the BeginProcessLoan method of the XML Web service.
After the XML Web service returns its response, a thread will invoke the callback from the threadpool. D. Supply a callback delegate to the EndProcessLoan method of the XML Web service.
After the XML Web service returns it response, a thread will invoke the callback from the threadpool. www.correctexams.com
- 61 -
Fast Way to get your Certification
Answer: C
Explanation: Calling an XML Web service asynchronously is a two-step operation. The first step, calling the Begin method, initiates the XML Web service call. The second step, calling the End method, completes the XML Web service call and returns the XML Web service response.
There are different methods to determine when the asynchronous XML Web service call has completed. The preferred and most efficient method is to supply a callback delegate to the Begin method.
Reference: Visual Basic and Visual C# Concepts, Accessing an XML Web Service Asynchronously in
Managed Code
Incorrect Answers
A, C: It is possible to use IAsyncResult.AsyncWaitHandle object to determine when the asynchronous
XML Web service call has completed. This is less efficient though.
D: The callback delegate should be supplied to the Begin method, not the End method.
QUESTION NO: 71
You use Visual Studio .NET to create an application that interact with a Microsoft SQL Server database. You create a SQL Server stored procedure named TestKOrderDetails and save it in the database. Other developers on your team frequently debug other stored procedures.
You need to verify that your stored procedure is performed correctly. You need to step through
CustOrderDetails inside the Visual Studio .NET debugger.
What should you do?
A.
B.
C.
D.
Run TestKOrderDetails by using the Visual Studio .NET Server Explorer.
Step into TestKOrderDetails by using the Visual Studio .NET Server Explorer.
From the Command window, use Ctrl+E to run TestKOrderDetails.
Move TestKOrderDetails from the Visual Studio .NET Server Explorer window to a Windows Form.
Run the application in Debug mode and step though TestKOrderDetails.
Answer: B
Explanation:
To debug a stored procedure from Server Explorer
1.
2.
3.
4.
Establish a connection to a database using Server Explorer.
Expand the database name node.
Expand the Stored Procedures node.
Right-click the stored procedure you want to debug and choose Step Into Stored Procedure from the shortcut menu.
Reference: Visual Studio, Debugging SQL Stored Procedures
QUESTION NO: 72
www.correctexams.com
- 62 -
Fast Way to get your Certification
You develop a Windows-based application named TestKingOrders. You implement the Trace object within your application code. You will use this object to record application information, such as errors and performance data, in a log file.
You must have the ability to enable and disable Trace logging. This functionality must involve the minimum amount of administrative effort.
What should you do?
A. Create a Boolean constant in your application named #TraceLogging and set it to False. Each time your code uses Trace logging, use a #if…#Then statement to evaluate your #TraceLogging constant.
B. On each computer that will host your application, create an environment variable named
CustOrders.Trace. Set the environment variable to True when you want to enable Trace logging. Set it to False when you want to disable Trace logging.
C. On each computer that will host your application, edit the shortcut used to start your application. Add
/d:TRACE=True to the Target property.
D. Use the TraceSwitch class within your code. Each time your code uses Trace logging, consult the
TraceSwitch level to verify whether to log information. Change the TraceSwitch level by editing your applications .config.file.
Answer: D
Explanation: By placing Trace Switches in your code, you can control whether tracing occurs and how extensive it is.
Reference:
Visual Basic and Visual C# Concepts, Introduction to Instrumentation and Tracing
Visual Basic and Visual C# Concepts, Trace Switches
QUESTION NO: 73
You develop a Windows-Based application that accesses a Microsoft SQL Server database named
TestKing1. Users must supply a user name and password when they start the application. This information is then used to dynamically build a connection string.
When you test the application, you discover that it is not using the SqlClient connection pooling feature. You must reduce the time needed to retrieve information.
How should you modify the connection string?
A.
B.
C.
D.
to use the Windows user logon when connection to the TestKing1 database. to use the SQL Server used login when connection to the TestKing1 database. to use the same application logon ID and password for every connection to the TestKing1 database. to use the guest login ID and password for every connection to the TestKing1 database.
Answer: C
Explanation: We must use the same connection string to only use one connection pool.
www.correctexams.com
- 63 -
Fast Way to get your Certification
Note: The performance of the application can be enhanced by having the application share, or "pool," connections to the data source. When a connection is opened, a connection pool is created based on an exact matching algorithm that associates the pool with the connection string in the connection. Each connection pool is associated with a distinct connection string. When a new connection is opened, if the connection string is not an exact match to an existing pool, a new pool is created.
Reference:
.NET Framework Developer's Guide, Connection Pooling for the SQL Server .NET Data Provider
Visual Basic and Visual C# Concepts, Introduction to ADO.NET Connection Design Tools
Incorrect Answers
A, C:
If we use different connection strings for different users we would not be using the same connection pool.
D: Using the guest login ID is not good out of security reasons.
QUESTION NO: 74
You use Visual Studio .NET to create a component TestKingShared that will be shared by two client applications. Eventually, you plan to deploy new version of TestKingShared. However, not all of the new versions will be compatible with both client applications.
When you deploy TestKingShared and the client applications, you must ensure that you can upgrade the TestKingShared for a single client application. You must also minimize the need for configuration changes when you deploy new version of the component.
What are two possible ways to achieve your goal? (Each correct answer presents a complete solution.
Choose two)
A. Deploy each client application to its own folder.
Deploy TestKingShared to its own folder.
Register TestKingShared by using RegSvr32 with the /s option.
B. Deploy each client application to its own folder.
Deploy a separate copy of TestKingShared to each client application folder.
When you deploy a new version of TestKingShared, replace the older version only if the new version remains compatible with the client application in the same folder.
C. Compile the client applications with reference to TestKingShared.
Deploy both client applications and TestKingShared to a single folder.
When you deploy a new version of TestKingShared, increment its version number.
D. Create a strong name of TestKingShared and specify a version number.
Compile each client application and bind it to TestKingShared.
Deploy TestKingShared to the global assembly cache on the client computer.
Deploy each client application to its own folder.
When you deploy a new version of TestKingShared, increment its version number.
Answer: B, D
Explanation:
B: We keep two separate copies of the shared component. And we only replace the shared copy of the component if compatibility is still maintained.
www.correctexams.com www.correctexams.com - 64 -
Fast Way to get your Certification
D: You can install multiple versions of the same assembly to the Global Assembly Cache, and applications can locate and use the appropriate version.
References: 70-306/70-316 Training kit, Understanding Private and Shared Assemblies, Pages 433-434
Incorrect Answers
A: RegSrv32 was used in Visual Basic 6.0 and Visual C++ 6.0 and earlier. It is no longer used in Visual
Studio .Net.
C: The shared component might be compatible with both client applications. We should use the global assembly cache, not put TestKingShared and the client applications in the same folder.
QUESTION NO: 75
You use Visual Studio .NET to create a Windows-based application. On the main application form,
TestKingFormMain, you create a TextBox control named textConnectionString. Users can enter a database connection string in this box to access customized data from any database in your company.
You also create a Help file to assist users in creating connection strings. The Help file will reside on your company intranet.
Your application must load the Help file in a new browser window when the user presses F1 key, but only of textConnectionString has focus. You must create this functionality by using the minimum amount of code.
In which event should you write the code to display the Help file?
A.
B.
C.
D.
E.
textConnectionString_KeyPress textConnectionString_KeyDown textConnectionString_KeyUp textConnectionString_GiveFeedback textConnectionString HelpRequested
Answer: E
Explanation: The Control.HelpRequested Event occurs when the user requests help for a control. The
HelpRequested event is commonly raised when the user presses the F1 key or an associated contextsensitive help button is clicked. This would be the most straightforward solution and would require minimal code. Note: Key events occur in the following order:
1. KeyDown
2. KeyPress
3. KeyUp
Reference:
.NET Framework Class Library, Control.HelpRequested Event [C#]
.NET Framework Class Library, Control.KeyDown Event [C#]
Incorrect Answers
www.correctexams.com
- 65 -
Fast Way to get your Certification
A: The KeyPress event occurs when a key is pressed while the control has focus. The KeyPress event could be used to provide a solution, but it would require more code.
B: The KeyDown event occurs when a key is pressed while the control has focus.
C: The KeyUp occurs when a key is released while the control has focus.
D: The Control.GiveFeedback does not apply here. It occurs during a drag operation.
QUESTION NO: 76
Your company uses Visual Studio .NET to create a Windows-based application for TestKing. The application is named CustomerTracker, and it calls an assembly named Schedule.
Six months pass. The hospital asks your company to develop a new Windows-based application. The new application will be named EmployeeTracker, and it will also call Schedule. Because you anticipate future revisions to this assembly, you want only one copy of Schedule to serve both applications. Before you can use Schedule in EmployeeTracker, you need to complete some preliminary tasks.
Which three actions should you take? (Each correct answer presents part of the solution. Choose three) A.
B.
C.
D.
E.
F.
Create a strong name for Schedule.
Use side-by-se execution to run Schedule.
Install Schedule in the global assembly cache.
Move Schedule to the Windows\System32 folder.
Create a reference in EmployeeTracker to Schedule.
Create a reference in EmployeeTracker to CustomerTracker.
Answer: A, C, E
Explanation:
A: An assembly must have a strong name to be installed in the global assembly cache.
C: You intend to share an assembly among several applications, you can install it into the global assembly cache. E: We must create a reference from the application (EmployeeTracker) to the assembly (Schedule).
Reference:
.NET Framework Developer's Guide, Working with Assemblies and the Global Assembly Cache
.NET Framework Developer's Guide, Side-by-Side Execution
Incorrect Answers
B: Side-by-side execution is the ability to run multiple versions of the same assembly simultaneously. It is not required in this scenario.
D: The assembly should be moved to the global assembly cache, not to the Windows\System32 folder.
F: The application should reference the assembly, not the first application.
QUESTION NO: 77
www.correctexams.com
- 66 -
Fast Way to get your Certification
You are preparing a localized version of a Windows Form named TestKingLocal. Users of
TestKingLocal speak a language that prints text from right to left. User interface elements on the form need to conform to this alignment.
You must ensure that all user interface elements are properly formatted when the localized Windows
Form runs. You must also ensure that TestKingLocal is easy to update and maintain.
What should you do?
A.
B.
C.
D.
Set the RightToLeft property of each control on the form to Yes.
Set the RightToLeft property of the form to Yes.
Set the Language property of the form to the appropriate language.
Set the Localizable property of the form to True.
Answer: B
Explanation: The RightToLeft property is used for international applications where the language is written from right to left
Reference:
Visual Basic and Visual C# Concepts, Displaying Right-to-Left Text in Windows Forms for Globalization
Incorrect Answers
A: The RightToLeft property can be set either to controls or to the form. The best solution is to set the property only for the form.
C: The Language property is not used to format text.
D: The Localizable property is not used to format text.
QUESTION NO: 78
You create an assembly by using Visual Studio .NET. The assembly is consumed by other .NET applications to manage the creation and deletion of XML data files.
The assembly includes a method named DeleteTestKXMLFile that uses the Win32 API to delete the
XML data files. A security exception is thrown when DeleteTestKXMLFile is called from another
.NET application.
You must modify DeleteXMLFile to ensure that this method can execute functions exposed by the
Win32 API. To do so, you create a SecurityPermission object that represents the right to call unmanaged code.
Which method of the SecurityPermission object should you call?
A.
B.
C.
D.
Assert
Demand
PermitOnly
RevertDeny
Answer: A
www.correctexams.com www.correctexams.com - 67 -
Fast Way to get your Certification
Explanation: The CodeAccessPermission.Assert Method asserts that calling code can access the resource identified by the current permission through the code that calls this method, even if callers higher in the stack have not been granted permission to access the resource.
Reference:
.NET Framework Class Library, SecurityPermission Class [C#]
.NET Framework Class Library, SecurityPermission Methods
.NET Framework Class Library, CodeAccessPermission.Assert Method [C#]
Incorrect Answers
B: The CodeAccessPermission.Demand method will not grant proper permission to other .NET applications. It forces a SecurityException at run time if all callers higher in the call stack have not been granted the permission specified by the current instance.
C: The CodeAccessPermission.PermitOnly method will not grant proper permission to other .NET applications. It prevents callers higher in the call stack from using the code that calls this method to access all resources except for the resource specified by the current instance.
D: RevertDeny is not a SecurityPermission method.
QUESTION NO: 79
You develop a Windows-based application that contains a form named ContactTestKing. You need to write code to initialize all class-level variables in ContactTestKing as soon as ContactTestKing is instantiated. You will place your code in a public procedure in the ContactTestKing class.
Which public procedure should you use?
A.
B.
C.
D.
Create
Initialize
Load
New
Answer: C
Explanation: The Form.Load Event occurs before a form is displayed for the first time. You can use this event to perform tasks such as allocating resources used by the form.
Reference:
.NET Framework Class Library, Form.Load Event [C#]
Incorrect Answers
A: Create does not apply here.
B: In Visual Basic 6.0, the Initialize event was used to execute code before a form was loaded. There is not such event in C# :NET.
D: New is not a public procedure. It is a class constructor.
QUESTION NO: 80
www.correctexams.com
- 68 -
Fast Way to get your Certification
You use Visual Studio .NET to create a Windows-based application called TestKingMortage. The main form of the application contains several check boxes that correspond to application settings. One of the CheckBox controls is named advancedCheckBox. The caption for advancedCheckBox is
Advanced.
You must enable users to select or clear this check box by pressing ALT+A.
Which two actions should you take? (Each correct answer presents part of the solution. Choose two)
A.
B.
C.
D.
E.
F.
G.
H.
Set advancedCheckBox.AutoCheck to True.
Set advancedCheckBox.AutoCheck to False.
Set advancedCheckBox.Text to “&Advanced”.
Set advancedCheckBox.Tag to “&Advanced”.
Set advancedCheckBox.CheckState to Unchecked.
Set advancedCheckBox.CheckState to Indeterminate.
Set advancedCheckBox.Apperance to Button.
Set advancedCheckBox.Apperance to Normal.
Answer: A, C
Explanation:
A: The AutoCheck property must be set to True so that the CheckBox automatically is changed when the check box is accessed.
C: The Text property contains the text associated with this control. By using the &-sign we define a shortcut command for this control. "@Advanced" defines the shortcut ALT+A.
Reference:
.NET Framework Class Library, CheckBox Properties
.NET Framework Class Library, CheckBox.AutoCheck Property [C#]
Incorrect Answers
B: If AutoCheck is set to false, you will need to add code to update the Checked or CheckState values in the
Click event handler.
D: The Tag property only contains data about the control.
E, F: The CheckState property only contains the state of the check box.
G, H: The appearance property only determines the appearance of a check box control.
QUESTION NO: 81
You use Visual Studio .NET to create several Windows-based applications. All use a common class library assembly named TestKingCustomers. You deploy the application to client computers on your company intranet.
Later, you modify TestKingCustomers.Any application that uses version 1.0.0.0 must now user version 2.0.0.0.
What should you do?
A. Modify the machine configuration file on your client computers.
B. Modify the application configuration file for Customers.
C. Modify the Publisher Policy file containing a reference to Customers.
www.correctexams.com
- 69 -
Fast Way to get your Certification
D. Modify the reference patch for Customers.
Answer: C
Explanation: When an assembly vendor releases a new version of an assembly, the vendor can include a publisher policy so applications that use the old version now use the new version.
Reference:
.NET Framework General Reference, Element
QUESTION NO: 82
You use Visual Studio .NET to create a Windows-based application. The application includes a form named TestKing. You implement print functionality in TestKing by using the native .NET System
Class Libraries.
TestKing will print a packing list on tractor-fed preprinted forms. The packing list always consists of two pages. The bottom margin of page 2 is different from the bottom margin of page 1.
You must ensure that each page is printed within the appropriate margins.
What should you do?
A.
B.
C.
D.
When printing page 2, set the bottom margin by using the PrintPageEventArgs object.
When printing page 2, set the bottom margin by using the QueryPageSettingEventArgs object.
Before printing, set the bottom margin of page 2 by using the PrintSetupDialog object.
Before printing, set the bottom margin of page 2 by using the PrinterSettings object.
Answer: A
Explanation: The PrintPageEventArgs Class provides data for the PrintPage event. The Printpage event occurs when the output to print for the current page is needed. Using the PrintPageEventArgs Class we can provide individual settings for a printed page, as is required in this scenario,.
It is possible to print each page of a document using different page settings. You set page settings by modifying individual properties of the QueryPageSettingsEventArgs.PageSettings property. Changes made to the PageSettings affect only the current page, not the document's default page settings.
The PageSettings Class specifies settings that apply to a single, printed page. It is used to specify settings that modify the way a page will be printed.
Reference:
.NET Framework Class Library, PrintDocument.PrintPage Event
.NET Framework Class Library, PrintDocument.QueryPageSettings Event [C#]
.NET Framework Class Library, PrintDocument.PrintPage Event [C#]
Incorrect Answers
B: QueryPageSettingsEventArgs Class Provides data for the QueryPageSettings event. However, the
PrintDocument.QueryPageSettings Event occurs immediately before each PrintPage event, not when a page is printed.
C: PrintSetupDialog object cannot be used to specify specific print settings of page 2.
www.correctexams.com
- 70 -
Fast Way to get your Certification
D: The PrinterSettings object sets general Printer properties. It does no apply here.
QUESTION NO: 83
You develop a customer contact application TestKingContact, that will enable users to view and update customer data in a Windows Form. Your application uses a DataTable object and a
DataAdapter object to manage the data and interact with a central database.
Your application design must fulfill the following requirements:
•
•
After a user completes a set of updates, the changes must be written in the database.
The data stored in the DataTable object must indicate that the database updates are complete.
What code segment should you use?
A. DataTable.AcceptChanges();
DataAdapter.Update(DataTable);
B. DataAdapter.Update(DataTable);
DataTable.AcceptChanges();
C. DataTable.Reset();
DataAdapter.Update(DataTable);
D. DataAdapter.Update(DataTable);
DataTable.Reset();
Answer: B
Explanation: First we resolve the changes (update) and then we commit them (AcceptChanges).
Note: The Update method of the DataAdapter is called to resolve changes from a DataSet back to the data source. The DataAdapter analyzes the changes that have been made and executes the appropriate command
(INSERT, UPDATE, or DELETE).
The DataTable.AcceptChanges Method commits all the changes made to this table since the last time
AcceptChanges was called.
Reference:
.NET Framework Class Library, DataTable.AcceptChanges Method [C#]
.NET Framework Developer's Guide, Updating the Database with a DataAdapter and the DataSet [C#]
.NET Framework Class Library, DataTable.Reset Method [C#]
Incorrect Answers
A: We must first update the changes to the DataTable before we commit the data source. We must swap the commands. C, D: The DataTable.Reset Method resets the DataTable to its original state. We should instead commit all changes with the AcceptChanges method.
www.correctexams.com
- 71 -
Fast Way to get your Certification
QUESTION NO: 84
You use Visual Studio .NET to create a custom control named TestKingStats. TestKingStats will operate by periodically polling your network and updating the network statistics displayed to each user. TestKingStats contains a Timer control named Timer1. You set the control’s Interval property to 500 milliseconds. You write code in the Tick event handler for Timer1 to poll the network status. You also create a procedure named RedrawControl to update the statistics displayed in TestKingStats.
When the form that contains TestKingStats is minimized or hidden behind another window, the control should not consume unnecessary resources by updating the display. You must ensure that this condition is met. In addition, you want to write the minimum amount of code needed to finish developing Stats.
Which two actions should you take? (Each correct answer presents part of the solution. Choose two)
A. Place the following code segment in the Tick event handler for Timer1:
RedrawControl();
B. Place the following code segment in the Tick event handler for Timer1: this.Invalidate(); C. Place the following code segment in the Tick event handler for Timer1:
If (this.Visible = True) this.Invalidate();
D. Place the following code segment in the Tick event handler for Time1:
If (this.Visible = True) this.Invalidate();
E. Place the following code segment in the Paint event handler for Stats:
RedrawControl(1);
F. Place the following code segment in the Paint event handler for Stats: this.Invalidate; Answer: D, E
Explanation:
D: We test if the form is visible (this.Visible = True) and then invalidate the form.
Note: The Invalidates method invalidates a specific region of the control and causes a paint message to be sent to the control. It will cause the Paint event of the Stats control to fire.
E: The invalidate method of the form will cause a paint event of the Stats control. We handle this by adding the RedrawControl() method to the Paint Event of the Stats control.
Reference:
.NET Framework Developer's Guide, Rendering a Windows Forms Control [C#]
.NET Framework Class Library, Control.Invalidate Method () [C#]
Incorrect Answers
A: We should only use RedrawControl if the form is visible. Furthermore we should put RedrawControl() in the Paint event handler for stats, not in Tick event for Timer1.
B: We should only use RedrawControl if the form is visible.
C: We should put RedrawControl() in the Paint event handler for stats, not in Tick event for Timer1.
F: We should put RedrawControl() in the Paint event handler for the Stats control. We should use the
Invalidate method in Tick event for Timer1, not in the Paint event handler for Stats.
www.correctexams.com
- 72 -
Fast Way to get your Certification
QUESTION NO: 85
You develop a Windows-based application that enables users to update customer contact information.
Your application uses a DataSet object to maintain the customer data while users are reviewing and editing it. When a user finishes updating the data, your application uses the DataSet.WriteXml method to create an XML data file.
The tag name of the root element of the XML data file must be . You need to add code to your application to ensure that this tag name is set correctly.
Which code segment should you use?
A.
B.
C.
D.
dsCustomer.Namespace = “TestKingCustomerInfo” dsCustomer = New DataSet(“TestKingCustomerInfo”) dcCustomer.Prefix = “TestKingCustomerInfo” dsCustomer.WriteXml(“TestKingCustomerInfo”) Answer: A
Explanation: The DataSet.Namespace Property gets or sets the namespace of the DataSet. The Namespace property is used in the root element of the XML data file generated from the dataset.
Reference:
.NET Framework Class Library. DataSet.Namespace Property [C#]
.NET Framework Class Library, DataSet.WriteXml Method (XmlWriter) [C#]
.NET Framework Class Library, DataSet.Prefix Property [C#]
Incorrect Answers
B: The name of the dataset does not decide the name of the root element of the XML data file.
C: The DataSet.Prefix Property gets or sets an XML prefix that aliases the namespace of the DataSet. The
Prefix is used throughout an XML document to identify elements which belong to the namespace of the
DataSet object as set by the Namespace property.
D: The WriteXml method requires a XmlWriter parameter, not a Text parameter.
QUESTION NO: 86
You use Visual Studio .NET to create a Windows Service application TestKingApp. You compile a debug version and install it on your computer, which runs Windows 2000 Server. You start
TestKingApp from the Windows 2000 Service Control Manager. Now you need to begin debugging it within Visual Studio .NET.
What should you do?
A. Add a reference to the application within Visual Studio .NET. Add breakpoints to the code.
Invoke the breakpoints by sending Stop, Pause, and Continue commands from the Service Control
Manager.
B. Select Processes from the Debug menu and attach the debugger to TestKingApp.
C. Place a breakpoint in the OnStart method of the application and then run it.
D. Place a breakpoint in the Main procedure of the application and then run it.
www.correctexams.com www.correctexams.com - 73 -
Fast Way to get your Certification
Answer: B
Explanation: To debug a service, you must start the service and then attach a debugger to the process in which it is running. We use the Process dialog box to attach to the running service.
Note: The Processes dialog box enables you to view and manipulate programs in a Visual Studio solution.
Using this dialog box, you can debug multiple programs at the same time in a single solution.
Reference:
Visual Basic and Visual C# Concepts, Debugging Windows Service Applications
Visual Studio, Processes Dialog Box
Incorrect Answers
A: The service is run with in the context of the Services Control Manager, not within Visual Studio .NET.
We cannot debug a process by adding a reference to the process and adding breakpoints.
C: Because the service has already been started, you cannot debug the code in the service's OnStart method.
D: Because the service has already been started, you cannot debug the code in the main procedure of the service. QUESTION NO: 87
You develop a Windows-based application that contains a class named TestKingContact.
TestKingContact used ADO.NET to interact with a Microsoft SQL Server database. TestKingContact requires an active connection to the database while it is being consumed.
You must ensure that all resources used by TestKingContact are properly releases as soon as the class stops being consumed.
What should you do?
A. In Contact, create a Sub procedure named Finalize to override System.Object.Finalize.
Place the appropriate cleanup code in the Finalize procedure and call MyBase.Finalize.
B. In Contact, create a Sub procedure named Closed.
Place the appropriate cleanup code in the Closed procedure.
C. Implement the Dispose method of the IDisposable interface.
Place the appropriate cleanup code in the implemented Dispose method.
Call the Dispose method of your form before releasing the reference.
D. Implement the Finalize method if the System.Windows.Form interface.
Place the appropriate cleanup code in the implemented Finalize method.
Call the Dispose method of your form before releasing the reference.
Answer: C
Explanation: We implement the IDisposable interface. It has one method Dispose. We implement the
Dispose method to release the open database connections. We must explicitly call Dispose method when the resources should be released.
Reference:
Visual Basic and Visual C# Concepts, Initialization and Termination of Components
www.correctexams.com
- 74 -
Fast Way to get your Certification
.NET Framework Developer's Guide, Overriding the Finalize Method
Incorrect Answers
A, D: As a good practice an object's Finalize method should not call a method on any objects other than that of its base class. It is inappropriate to close database in the Finalize method of the form.
B: A forms closed event occurs when the form is closed. Cleanup code should not be placed in procedure named Closed. We could not be absolutely sure that the database is no longer used.
QUESTION NO: 88
You develop a Windows-based customer service application that includes a search feature. Users will enter characters in a text box to look up customer information by family name.
For convenience, users must be able to perform a search by entering only the first few characters of the family name. To enable this functionality, your application will capture the users input and stores it in a variable named TKName. Your application must then submit a Microsoft SQL Server query to the central customer service database.
How should you write the query?
A. SQL = “SELECT PersonalName, FamilyName FROM “ & _
“Customers WHERE FamilyName = ‘” & TKName & “%’”
B. SQL = “SELECT” PersonalName, FamilyName FROM “ & _
“Customers WHERE FamilyName LIKE ‘” & TKName & “%’”
C. SQL = SELECT PersonalName, FamilyName FROM “ & _
“Customers WHERE FamilyName = ‘” & TKName & “*’”
D. SQL = “SELECT PersonalName, FamilyName FROM “ & _
“Customers WHERE FamilyName LIKE ‘” & TKName & “*’”
Answer: B
Explanation: The SQL server LIKE Transact-SQL command LIKE determines whether or not a given character string matches a specified pattern. % is used as a wildcard character.
Reference: SQL Server Books Online, LIKE
Incorrect Answers
A: We must use the LIKE keyword.
C: We must use the LIKE keyword with the % wildcard character.
D: %, not *, is used as a wildcard character.
QUESTION NO: 89
You use Visual Studio .NET to create an accounting application called TestKingAccounting, which includes a function named CreditCardValidate. This function contains several dozen variables and objects. To debug CreditCardValidate, you create a breakpoint at the top of the function. You run the accounting application within the Visual Studio .NET IDE and step though the code for
www.correctexams.com
- 75 -
Fast Way to get your Certification
CreditCardValidate. You need to examine the contents of the variables and objects in scope on each line of code. However, you want to avoid seeing the contents of all variables and objects within
CreditCardValidate. You also need to complete the debugging process as quickly as possible.
What should you do?
A.
B.
C.
D.
Use the Autos window.
Use the Locals window.
Use the QuickWatch window.
From the Command window, print the contents of each variable that you want to examine by using the following code segment:
?
Answer: B
Explanation: The Locals window displays variables local to the current context.
Reference:
Visual Studio, Using the Locals Window
Visual Studio, Using Autos Window
Visual Studio, Using the QuickWatch Dialog Box
Incorrect Answers
A: The Autos window displays variables used in the current statement and the previous statement only.
C: The QuickWatch Dialog Box, there is no QuickWatch window, is used to quickly evaluate a variable or expression, or edit the value of a variable or register. It is not used to display values of several variables.
D: This would require much manual labor.
QUESTION NO: 90
You develop a contact management application called TestKingManagement that will enable users to retrieve information from a central database. After the data is returned to TestKingManagement, users must be able to view it, edit it, add new records, and delete existing records. All user changes must then be saved in the database.
TestKingManagement design requires several ADO.NET objects to work together to accomplish these requirements. You use classes from the System.Data and System.Data.OleDb namespaces.
First you write the code to connect to the database. Which four actions should you take next? (Each correct answer presents part of the solution. Choose four.)
A.
B.
C.
D.
E.
F.
G.
H.
Create an OleDbDataAdapter object and define the SelectCommand property.
Create an OleDbCommand object and use the ExecuteScalar method.
Create a DataTable object as a container for the data.
Create a DataSet object as a container for the data.
Call the DataAdapter.Fill method to populate the DataSet object.
Call the DataAdapter.Update method to populate the DataSet object.
Call the DataAdapter.Update method to save changes to the database.
Call the DataSet.AcceptChanges method to save changes to the database.
www.correctexams.com
- 76 -
Fast Way to get your Certification
Answer: A, D, E, G
Explanation:
A: First we must create a DataAdapter.
D: We then use a DataSet object as a container for the data.
E: We use the Fill method to populate the DataSet.
G: Finally we update the data source with the Update method.
Reference:
Visual Basic and Visual C# Concepts, Introduction to Dataset Updates
.NET Framework Developer's Guide, Using .NET Data Providers to Access Data
.NET Framework Class Library, DbDataAdapter.Fill Method [Visual Basic]
.NET Framework Developer's Guide, Updating the Database with a DataAdapter and the DataSet [Visual
Basic]
Incorrect Answers
B: We need a DataAdapter to populate the DataSet.
C: DataTables contains the actual data. We must a DataSet instead. A DataSet is an in-memory representation of relational data.
F: The Fill method, not the Update method, is used to populate the DataSet.
H: The AcceptChanges method is to commit the pending changes to the Dataset, not to the data source (the database). QUESTION NO: 91
You develop a Windows-based application that uses several functions to calculate a given inventory quantity. This quantity is stored in a variable named TestKingQuantity.
When you test your application, you discover that the value of TestKingQuantity sometimes falls below zero. For debugging purposes, you want your application to generate an error message in such cases. You also want to be able to view the call stack to help identify the function call that is causing the miscalculation.
You need to insert additional code after the calculation of TestKingQuantity.
Which code segment should you use?
A. Trace.Assert(TestKingQuantity >= 0, _
“Inventory cannot be less than zero.”);
B. Trace.Assert(TestKingQuantity < 0, _
“Inventory cannot be less than zero.”);
C. Trace.Fail(TestKingQuantity >= 0, _
“Inventory cannot be less than zero.”);
D. Trace.WriteLineIf(TestKingQuantity < 0, _
“Inventory cannot be less than zero.”);
Answer: A
www.correctexams.com
- 77 -
Fast Way to get your Certification
Explanation: The Assert method emits output as a message box if the condition is false. If
TestKingQuantity