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 { 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
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. 

2. 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. SetShowHelp
B. SetHelpString 
C. SetHelpKeyword 
D. 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. 

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 e) { CleanUp(e); }
B. try { TestKing(); } catch (Exception e) { LogError(e); CleanUp(); } 
C. try { TestKing(); } catch (Exception e) { LogError(e); } finally { CleanUp(); } 
D. try { TestKing(); } catch (Exception e) { CleanUp(e); } finally { LogError(); } 

Answer: C 

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. 
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. 

4. You use Visual Studio .NET to create a Windows-based application. The application includes a form 
named TestKForm, which displays statistical data 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. Set TestKForm.MinimizeBox to False. 
B. Set TestKForm.MaximizeBox to False. 
C. Set TestKForm.ControlBox to False. 
D. Set TestKForm.ImeMode to Disabled. 
E. Set TestKForm.WindowState to Maximized. 
F. Set TestKForm.FormBorderStyle to one of the Fixed Styles. 
G. 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

5. 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. } 
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.. 
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. D: The 
association between the delegate an the event is incorrect. The += operator must be used: new 
EventHandler(HandleContactSaved) 
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. Execute the Add method of the TextBoxes DataBindings collection and pass in TestKingDataSet.
B. Execute the BeginInit method of TestKingDataSet.
C. Execute the Open method of TestKingConnection.
D. Execute the FillSchema method of TestKingDataAdapter and pass in TestKingDataSet. 
E. 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.

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. 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. Set the MinimumSize property to "500,600". 
B. Set the MinimumSize property to "650,700". 
C. Set the MinimizeBox property to True.
D. Set the MaximumSize property to "500,600". 
E. Set the MaximumSize property to "650,700". 
F. Set the MaximumBox property to True. 
G. Set the Size property to "500,600".
H. 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". 
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. 

8. You are 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");}
finally { Debug.WriteLine ("Inside Finally");}
 Debug.WriteLine ("After End Try"); 
Which output is produced by this 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. 
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. 

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 selects the Groups menu, the two 
submenus will be displayed. The user can select only one group of soldiers at a time. 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 selected 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; 
Incorrect Answers B: This is not the way to define Access keys. The & sign must be used. 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. 

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. this.BackColor = Color.Transparent; 
B. this.ForeColor = Color.Transparent; 
C. this.BackImage = null; 
D. this.SetStyle(ControlStyles.UserPaint, false);
E. 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; 

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:  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. 
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. D: ActiveX controls 
should be avoided in Visual Studio .NET. They are less efficient. 

12. You are a developer for 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
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). 

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. 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 
prints debug information. E: We enable debugging by entering DEBUG to the Conditional Compilation 
Constants option. 
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. 

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 { } 
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. public Testking() 
B. public void Testking () 
C. public bool Testking () 
D. public New() 
E. public Testking New()
F. public 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 no return type, not even void. 
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. 

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. Contact contact = new Object();
B. Contact contact = new Contact; 
C. Object contact = new Contact;
D. 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
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; 

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. Install MDAC 2.7. 
B. Install Internet Explorer 6. 
C. Install the redistribute package for the .NET Framework. 
D. 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. 
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 solve the problem 

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 
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. 

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. 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
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. 

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 { } 
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. 
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.. 

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

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)
 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. 
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 
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. In the BeginPrint event, set the HasMorePages property of the PrintEventArgs object to True.
 B. In the EndPrint event, set the HasMorePages property of the PrintEventArgs object to True. 
C. In the PrintPage event, set the HasMorePages property of the PrintPageEventArgs object to True. 
D. In the QueryPageSettings event, set the HasMorePages property of the QueryPageSettingEventArgs 
object to True. 
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
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 logging 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). 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..
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 of 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 
24. Your 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
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. 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. 
25. Your 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: By creating a destructor for TestKingAccounts class we can ensure that appropriate actions are 
performed before TestKingAccounts is terminated 
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 your 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. 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
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. 
27. You use Visual Studio .NET to develop a Windows-Based 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. 
B. Create a new instance of the WindowsImpersonationContext class by calling the Impersonate method of 
the WindowsIdentity 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. 
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 be named TestKingMgmt.exe.config and be placed in the 
application folder. 
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. 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. 
Incorrect Answers A: We should not use the current identify, 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  assign roles to a user. D: We should not use the anonymous 
identify, instead we should use the identity entered in the UserName textbox. 
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
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. 
31. 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. Use XCOPY to install the assembly in the global assembly cache. 
B. Use XCOPY to install the assembly in the Windows\Assembly folder. 
C. Create a strong name for the assembly. 
D. Recompile the assembly by using the Native Image Generator (Ngen.exe). 
E. Modify the application configuration file to include the assembly. 
F. Use a deployment project to install the assembly in the global assembly cache. 
G. 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
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. 
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. 
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..: 
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. How should you 
implement this functionality? 
A. Set the RowFilter property of the DataView object to "BackOrder = True". 
B. Set the RowStateFilter property of the DataView object to "BackOrder = True". 
C. Set the Sort property of the DataView object to "BackOrder = True". 
D. 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
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. 
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. 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
 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. 
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. Sign your portable executables by using Signcode.exe.
 B. Generate an X.509 certificate by using Makecert.exe. 
C. Purchase an X.509 certificate from a certificate authority. 
D. Purchase a Software Publisher Certificate from a certificate authority. 
E. 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
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. 
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 ensure 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. 
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. 
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. 
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. 
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. 
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. 
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. 
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 
40.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. tr = cn.BeginTransaction("ReadCommitted");
B. tr = cn.BeginTransaction(IsolationLevel.ReadCommitted); 
C. tr = cn.BeginTransaction(IsolationLevel.Serializable); 
D. tr = cn.BeginTransaction("Serializable"); 
Answer: C 
Explanation: Serializable is the highest isolation transaction level. It provides 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) 
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. 
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. 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 use 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
 Incorrect Answers A: We must use 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. 
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. What should you do?
 A. Use the DataSet.Reset method. 
B. Set the RowFilter property of the DataSet object by using a filter expression. 
C. Create a DataView object and set the RowFilter property by using a filter expression. 
D. 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. 
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. 
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; 

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
 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. 
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. Use the DataSet.Merge method. 
B. Define primary keys for the Data Table objects. 
C. Create a foreign key constraint on the DataSet object. 
D. Add a DataRelation object to the Relations collection of the DataSet object. 
Answer: D 
Explanation: We want to use data from both DataTable objects. 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. 
Incorrect Answers 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. 
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. 
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. 
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"].Value.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
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. D: We must use the 
Value method to retrieve the value of the parameter. 
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. 
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. 
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. 
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 { 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. 
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. ExecuteNonQuery 
B. ExecuteScalar 
C. ToString 
D. 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
 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. 
51. 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 o A?
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. 
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. Implement a DataSet object and code an event handler to process its events. 
B. Implement a DataSet object and set its Enforce Constraints property to True. 
C. Implement an XmlValidatingReader object and code an event handler to process its events.
 D. Implement an XmlValidatingReader object and examine its ReadState property after reading the XML 
data file. 
Answer: C 
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. 
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 ALTER PROCEDURE dbo.sp_UpdateTestKingPrice 
02 ( 
03 @category int, 
04 @totalprice money OUTPUT 
05 )
 06 AS 
07 SET NOCOUNT ON
08 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 
Your application uses the ExecuteReader method of the SqlCommand object to call the stored procedure 
and create a SqlDataReader object. After the stored procedure runs, 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 
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. 
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. 
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. Call the InsertCommand method of TestKingDataAdapter. 
B. Call the Update method of TestKingDataAdapter and pass in TestKingConnection. 
C. Before calling the Update method, ensure that a row position change occurs in CustomerDataSet. 
D. Reestablish the database connection by calling the Open method of TestKingConnection. 
Answer: B 
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); 
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. Include this.Activate in the Closing event handler of TestKingInformationForm. 
B. Include this.Activate in the Closed event handler of TestKingInformationForm. 
C. Include this.Activate in the Leave event handler of TestKingInformationForm. 
D. 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. 
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. 
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. Tag 
B. Next 
C. Name 
D. AccessibleName 
E. AccessibleRole 
Answer: D 
Explanation: The AccessibleName property is the name that will be reported to the accessibility aids. 
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. 
57. You use Visual Studio .NET to develop an application for users on 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. CAB project. 
B. merge module project. 
C. setup project. 
D. Web setup project. 
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. 
Incorrect Answers A: CAB projects allows 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. 
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. Author 
B. Comments 
C. Manufacturer 
D. 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. 
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- 
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. Perform declarative security checks. 
B. Perform imperative security checks. 
C. Perform all security checks by using SQL Server security. 
D. 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.  
Incorrect Answers B: 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. 
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 is the cause of this error? 
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. 
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. < Assembly: PermissionSet(SecurityAction.PermitOnly, Unrestricted := True) > 
B. < Assembly: PermissionSet(SecurityAction.PermitOnly, Unrestricted := False) > 
C. < Assembly: PermissionSet(SecurityAction.RequestOptional,Unrestricted = True) > 
D. < Assembly: PermissionSet(SecurityAction.RequestOptional, Unrestricted = False) > 
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
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. 
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. 
D. Set transparentPanel.Visible to False. 
E. Set CameraForm.Opacity to 0%. 
F. Set CameraForm.TransparencyKey to Red. 
G. 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. 
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. Call the DataSet.WriteXmlSchema method and specify a TextWriter object as the argument. 
B. Call the DataSet.WriteXmlSchema method and specify an XmlWriter object as the argument. 
C. Call the DataSet.WriteXml method and specify WriteSchema as the XmlWriteMode parameter. 
D. 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. 
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). 
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.
 Incorrect Answers A: There is no need for 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. 
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. 
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. 
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; 
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. 
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. 
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. 
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. 
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 handled, 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. 
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. 
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. 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. Use Disco.exe to generate a new proxy class for MortgageRate. 
B. Modify the TestKing3 code to pass the postal code to GetCurrentRate. 
C. Use the Update Web Reference menu item to update the reference to MortgageRate in TestKing3. 
D. Use the Add Reference dialog box to recreate the reference to MortgageRate in TestKing3. 
E. 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. 
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 is 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 finishes 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. 
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. 
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. 
71. You use Visual Studio .NET to create an application that interacts 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. Run TestKOrderDetails by using the Visual Studio .NET Server Explorer. 
B. Step into TestKOrderDetails by using the Visual Studio .NET Server Explorer. 
C. From the Command window, use Ctrl+E to run CustOrderDetails. 
D. Move TestKOrderDetails from the Visual Studio .NET Server Explorer window to a Windows Form. Run 
the application in Debug mode and step though CustOrderDetails. 
Answer: B 
Explanation: To debug a stored procedure from Server Explorer 1. Establish a connection to a database 
using Server Explorer. 2. Expand the database name node. 3. Expand the Stored Procedures node. 4. 
Right-click the stored procedure you want to debug and choose Step Into Stored Procedure from the 
shortcut menu. 
72. 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 an #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
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. to use the Windows user logon when connecting to the TestKing1 database. 
B. to use the SQL Server used login when connecting to the TestKing1 database. 
C. to use the same application logon ID and password for every connection to the TestKing1 database. 
D. 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. 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
Incorrect Answers A, B: 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. 
74. You use Visual Studio .NET to create a component TestKingShared that will be shared by two client 
applications. Eventually, you plan to deploy a 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 the 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. D: You can install multiple versions of the same 
assembly to the Global Assembly Cache, and applications can locate and use the appropriate version. 
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. 
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 if 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. textConnectionString_KeyPress 
B. textConnectionString_KeyDown 
C. textConnectionString_KeyUp 
D. textConnectionString_GiveFeedback 
E. 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 
Incorrect Answers 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. 
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. Create a strong name for Schedule. 
B. Use side-by-se execution to run Schedule. 
C. Install Schedule in the global assembly cache. 
D. Move Schedule to the Windows\System32 folder. 
E. Create a reference in EmployeeTracker to Schedule. 
F. 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). 
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. 
77. 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. Set the RightToLeft property of each control on the form to Yes. 
B. Set the RightToLeft property of the form to Yes. 
C. Set the Language property of the form to the appropriate language. 
D. 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 
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. 
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. Assert 
B. Demand 
C. PermitOnly 
D. RevertDeny 
Answer: A 
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
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. 
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. Create 
B. Initialize 
C. Load 
D. 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. 
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. 
80. 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. Set advancedCheckBox.AutoCheck to True. 
B. Set advancedCheckBox.AutoCheck to False. 
C. Set advancedCheckBox.Text to "&Advanced". 
D. Set advancedCheckBox.Tag to "&Advanced". 
E. Set advancedCheckBox.CheckState to Unchecked. 
F. Set advancedCheckBox.CheckState to Indeterminate. 
G. Set advancedCheckBox.Apperance to Button. 
H. 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. 
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. 
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 use 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. 
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. 
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. When printing page 2, set the bottom margin by using the PrintPageEventArgs object. 
B. When printing page 2, set the bottom margin by using the QueryPageSettingEventArgs object. 
C. Before printing, set the bottom margin of page 2 by using the PrintSetupDialog object. 
D. 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
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. D: The PrinterSettings object sets general Printer properties. It does no apply here. 
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
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. 
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 = False) 
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(); 
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
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. 
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 TestKingCustomerInfo . You 
need to add code to your application to ensure that this tag name is set correctly. Which code segment 
should you use? 
A. dsCustomer.Namespace = "TestKingCustomerInfo" 
B. dsCustomer = New DataSet("TestKingCustomerInfo") 
C. dsCustomer.Prefix = "TestKingCustomerInfo" 
D. 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. 
DataSet.WriteXml Method (XmlWriter)
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. 
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. 
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. 
Incorrect Answers A: The service is run within 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. 
87. You develop a Windows-based application that contains a class named TestKingContact. 
TestKingContact uses 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 released 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 in 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
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. 
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 store 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
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. 
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 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. Use the Autos window. 
B. Use the Locals window. 
C. Use the QuickWatch window. 
D. 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
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. 
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. Create an OleDbDataAdapter object and define the SelectCommand property. 
B. Create an OleDbCommand object and use the ExecuteScalar method. 
C. Create a DataTable object as a container for the data. 
D. Create a DataSet object as a container for the data. 
E. Call the DataAdapter.Fill method to populate the DataSet object. 
F. Call the DataAdapter.Update method to populate the DataSet object. 
G. Call the DataAdapter.Update method to save changes to the database. 
H. Call the DataSet.AcceptChanges method to save changes to the database. 

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
Incorrect Answers B: We need a DataAdapter to populate the DataSet. C: DataTables contains the actual 
data. We must use 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 
used to commit the pending changes to the Dataset, not to the data source (the database). 
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 
Explanation: The Assert method emits output as a message box if the condition is false. If TestKingQuantity 
<0 then the message box will appear and the user would be able to check the current call stack in the call 
stack window. 
Incorrect Answers B: The Assert method emits output if the condition is false. The condition is incorrect. C: 
The Fail method writes output unconditionally. It cannot be used with a condition. D: The WriteLineIf method 
emits output if the condition is true. Though the code will continue to run, so it would be impossible to check 
the call stack window at this point of time. 
92. You develop a Windows-based order entry application TestKingEntry by using Visual Studio .NET. 
TestKingEntry includes a DataSet object. When a customer order exceeds the number of items currently 
available in stock, TestKingEntry must create two separate entries in a database. The first entry specifies 
the total number of items in the customer order, as well as the number of items that can be supplied 
immediately from available stock. The second entry records backorder information, and specifies the 
number of items that must be supplied when new stock becomes available. Backorder processing is handled 
by a separate component. You must ensure that all order information in the DataSet object is captured and 
passed to this component. To do so, you need to create a new DataSet object. Which method should you 
use? 
A. DataSet.Clone 
B. DataSet.Copy 
C. DataSet.Merge 
D. DataSet.GetChanges 
Answer: D 
Explanation: The DataSet.GetChanges Method gets a copy of the DataSet containing all changes made to it 
since it was last loaded. It meets the requirement of this scenario. 
Incorrect Answers A: The DataSet.Clone method copies the structure of the DataSet, including all DataTable 
schemas, relations, and constraints. However it does not copy any data. B: DataSet.Copy method copies 
both the structure and data for this DataSet. But we are only interested in the changes. C: We want to create 
a new DataSet object, not merge two existing objects. 
93. You use Visual Studio .NET to create an application TestKingTestEngine that will be deployed to several 
client computers. You plan to create a setup package to distribute TestKingTestEngine. Because of 
licensing restrictions, you must ensure that the setup package can be installed only on computers that have 
a particular registry key. What should you do?
 A. Add a registry key to the setup project. Set the Transitive property of your key to True. 
B. From the Properties window, set the private key file option to the registry key. 
C. From the Launch Conditions window, add a search for the registry key. Add a launch condition to 
evaluate the search results. 
D. Open the setup project source code in Visual Studio .NET. Add code to search for the registry key and to 
abort the setup if the registry key does not exist on the client computer. Recompile setup1.exe and include it 
with your setup package. 
Answer: C 
Explanation: The Launch Conditions editor (window) is used to define conditions for the installations. The 
condition can be used in conjunction with a file, registry, or component search to terminate installation if a 
specified item is not found. 
Incorrect Answers A: The Transitive property cannot be used to stop the installation process if a registry key 
is missing. It determines whether the installer will reevaluate the Condition property for a selected folder, file, 
registry key, or registry value when installing or reinstalling on a target computer. B: Does not apply. D: This 
is not the way to do it. 
94. You develop a Windows-based application TestKiApp by using Visual Studio .NET. TestKiApp uses a 
SqlConnection object for database access. You typically run TestKiApp on a computer that has limited RAM 
and hard disk space. After the code finishes using the SqlConnection object, you must ensure that the 
connection is closed and that any resources consumed by the object are released immediately. What should 
you do? 
A. Call the Finalize method of the SqlConnection object. 
B. Call the Dispose method of the SqlConnection object. 
C. Set the SqlConnection object equal to Nothing. 
D. Set the SqlConnection object equal to "". 
Answer: B 
Explanation: SqlConnection.Dispose Method releases the unmanaged resources used by the SqlConnection 
and optionally releases the managed resources. Calling this method with Dispose releases both managed 
and unmanaged resources. 
Incorrect Answers A: The Finalize method invokes Dispose method but only the unmanaged resources are 
released. C, D: This is not the way to release the resources used by the SqlConnection object. 
95. You use Visual Studio .NET to develop a Windows-based application. Your application will display 
customer order information from a Microsoft SQL Server database. The orders will be displayed on a 
Windows Form that includes a DataGrid control named TestKingGrid1. TestKingGrid1 is bound to a 
DataView object. Users will be able to edit order information directly in TestKingGrid1. You must give users 
the option of displaying only edited customer orders and updated values in TestKingGrid1. What should you 
do? 
A. Set the RowStateFilter property of the DataView object to DataViewRowState.ModifiedOriginal. 
B. Set the RowStateFilter property of the DataView object to DataViewRowState.ModifiedCurrent. 
C. Set the RowFilter property of the DataView object to DataViewRowState.ModifiedOriginal. 
D. Set the RowFilter property of the DataView object to DataViewRowState.ModifiedCurrent. 
Answer: B 
Explanation: We must set the RowStateFilter property of the DataView to specify which version or versions 
of data we want to view. We should use the ModifiedCurrent. DataViewRowState which provides the 
modified version of original data. 
Incorrect Answers A, C: The ModifiedOriginal DataViewRowState is used to get the original version of the 
rows in the view. We are interested in the modified rows however. D: We are not applying a usual filter with 
the RowFilter property. We must use a RowStateFilter. 
96. You use Visual Studio .NET to create a Windows-based application named TestKingAccess. 
TestKingAccess will be used by five customer service representatives to access a central database. All five 
representatives use client computers that are connected to the company intranet. All client computers have 
Windows XP Professional and the .NET Framework installed. When you distribute TestKingAccess, you 
must ensure that it uses the smallest possible hard disk space on the client computers. What should you 
do? 
A. Copy your application to each client computer. Create a shortcut to your application on the desktop of 
each client computer. 
B. Copy your application to a shared folder on your company intranet. Create a shortcut to your application 
on the desktop of each client computer. 
C. Create a distribution package by using the Visual Studio .NET Setup Wizard. Exclude the dependency for 
the .NET Framework. Install the distribution package on each client computer. 
D. Create a distribution package by using the Visual Studio .NET Setup Wizard. Set the distribution 
package's Compression property to Optimized for size. Install the distribution package on each client 
computer. 
Answer: A 
Explanation: The .NET Framework is required on each system that runs Visual Basic .NET application. 
Installed the .NET Framework is 30 MB. Windows XP already has the .NET Framework included in the 
operating systems, so we don't have to distribute it. We can simply copy the application to each client 
computer and manually create a shortcut to the application. 
Incorrect Answers B: Running the application over the network simultaneously at 5 clients is not guaranteed 
to work. C: The .NET Framework is not included in distribution packages made by Visual Studio .NET. There 
is no need to remove it. D: This compression is only for the installation files. It would still require the same 
amount of disk space on the client computers. 
97. You develop a Windows-based inventory management application that interacts with a Microsoft SQL 
Server database. Your application enables users to update information about items in inventory. Each time a 
user changes an inventory item, your application executes a SQL Server stored procedure TestKingSP to 
update rows in the database. TestKingSP will run many times during each user session. Your application will 
use a SqlCommand object to execute TestKingSP. You must revise your code so that the use of this object 
optimizes query performance. What should you do? 
A. Call the SqlCommand.DeriveParameters method before each call to SqlCommand.ExecuteNonQuery. 
B. Call the SqlCommand.Prepare method before each call to SqlCommand.ExecuteNonQuery. 
C. Call the SqlCommand.DeriveParameters method before the first call to SqlCommand.ExecuteNonQuery.
 D. Call the SqlCommand.Prepare method before the first call to SqlCommand.ExecuteNonQuery. 
Answer: D 
Explanation: The SqlCommand.Prepare Method creates a prepared version of the command on an instance 
of SQL Server. It prepares a compiled version of the command on the data source. We only need to compile 
the stored procedure once. Compiling the procedure would improve performance since it will run many 
times. 
Note: Deriving parameter information does require an added trip to the data source for the information. If 
parameter information is known at design-time, you can improve the performance of your application by 
setting the parameters explicitly. 
Incorrect Answers A, C: We cannot be sure that the parameters are known at design time. So we cannot 
use the DeriveParameters method. B: We don't need to prepare (compile) the stored procedure before each 
call. 
98. You use Visual Studio .NET to develop a component named TestKingComponent. You plan to develop 
several client applications that use TestKingComponent. You need to deploy TestKingComponent with each 
of these applications. You will create a distribution package to be included with each application. Which type 
of project should you create? 
A. CAB project. 
B. merge module project. 
C. setup project. 
D. Web setup project. 
Answer: B 
Explanation Merge Module projects allow you to create reusable setup components. They create a merge 
module (.msm) file that includes all files, resources, registry entries, and setup logic for your component. The 
resulting .msm file can then be merged into other deployment projects, insuring consistent installation of 
your component across multiple applications. 
99. You develop a Windows-based application TestKingInvoice that enables users to enter and edit 
customer orders. TestKingInvoice contains a DataSet object named orderEntryDataSet and DataTable 
object named orderDataTable and orderDetailDataTable. The orderDetailDataTable requires two columns to 
make a unique primary key. You need to define a primary key for orderDetailDataTable. What should you 
do? 
A. Set the DataTable.PrimaryKey property to a string value that lists the column names that make the 
primary key. 
B. Set the DataTable.PrimaryKey property to an array of DataColumn objects that reference the columns 
that make the primary key. 
C. Iterate through the DataTable.Columns collection and set the DataType property of the columns that 
make the primary key. 
D. Create a UniqueConstraint on the columns that make the primary key. 
Answer: B 
Explanation: DataTable.PrimaryKey Property gets or sets an array of columns that function as primary keys 
for the data table. 
Incorrect Answers A: An array of columns, not a string value, is used with the PrimaryKey property. C: There 
can be only one primary key in a DataTable. D: The PrimeryKey property, not the UniqueConstraint, must be 
used. The PrimaryKey property enforces uniqueness as well. 
100. You use Visual Studio .NET to create a class library project. Another developer named Lilliane uses 
ASP.NET to create an Internet application for TestKing's Web site. Lilliane deploys your class library to the 
\bin folder of her ASP.NET application on TestKing's development Web server. She has access to your 
source code through a share on another network server. Lilliane reports that her application can instantiate 
and use classes from your class library. However, when she is debugging her application, she cannot step 
into code within your class library. You must ensure that developers who use your class library can step 
through the code for debugging purposes. Which three actions should you take? (Each correct answer 
presents part of the solution. Choose three) 
A. Use the Build Configuration Manager to set the Active Solution Configuration option to Debug. Set the 
Project Configuration to Debug. Build your class library. 
B. Add the class library project to the ASP.NET solution. 
C. Copy the .dll file from the Debug folder of the class library project to the \bin folder of the ASP.NET 
application. 
D. Copy the .pdb file from the Debug folder of the class library project to the \bin folder of the ASP.NET 
application. 
E. Copy the TempPE folder Debug folder of the class library project to the \bin folder of the ASP.NET 
application. 
F. Copy the source code for the class library to the ASP.NET application folder on the Web server. 
G. Register the class library on the Web server by using RegSvr32.exe. 
Answer: A, C, D 
Explanation: 
A: First we must build a Debug version of the class library. C: The Class Library creates a .dll file. This file 
should be copied to Web Server. D: In order to debug we need the program database file, the .pdb file. We 
copy it to the class library folder. This will allow Visual Studio .NET to find it and debugging would be 
possible. Note: A PDB (program database) file holds debugging and project state information that allows 
incremental linking of a Debug configuration of your program. A PDB file is created when you compile a 
C/C++ program with /ZI or /Zi or a Visual Basic/C# program with /debug. The Visual Studio debugger uses 
the project.PDB file created by the linker directly and embeds the absolute path to the PDB in the EXE or 
DLL file. If the debugger can't find the PDB file at that location or if the path is invalid (for example, if the 
project was moved to another computer), the debugger searches the path containing the EXE, the Symbol 
Path specified in the solution's Property Pages (Common Properties folder, Debug Symbol Files page). 
Incorrect Answers B: We only want to use and debug the class library. We don't need to use the class library 
project. E: We only need to copy the dll file of the Class Library, not an entire folder. F: The source code of 
the class library is not necessary in order to debug it. G: Regsrv32.exe was used to register components on 
computers in Visual Basic 6.0, Visual C++ 6.0 etc. Regsrv32 is not used for components that are produced 
by Visual Studio .NET. 
101. You have a label control on your form that displays current stock qoute. The background color of your 
form is customizable and you wish to show the background of the form as much as you can. You need to 
display only the stock quote in the label control and nothing else. Chose Two 
A. label1.BackColor = Color.Transparent 
B. label1.ForeColor = Color.Transparent 
C. label1.BackImage = null; 
D. label1.Style = ControlStyle(UserPaint,false); 
Answer: A, C 
The two most logical options are A & C. But the property BackImage doesnt exist. the other two (C & D) use 
ControlStyle and i didnt that that was the way to go, so i chose A & C. 
102. You have a form name myForm and a class myClass. Your form also contails a button button1. In 
button1's click event you must make sure that a new instance of myClass is created. You must use the most 
efficient way to do this. What shoud you do? 
A. myClass class = new Object(); 
B. myClass class = new myClass; 
C. Object class = new myClass; 
D. One more option dont quite remember.. but syntax was wrong. 
Answer: B 
This one was a reaaaal headache! I chose B even though the syntax is wrong according to me, cause option 
A would produce an InvalidCastException. Implicit cast from object to myClass is not allowed. C could also 
be used. Dont know abt this one. 
103. You create an application that involved customer information retrieval. You include tracing in the 
various functions to provide easy debugging as and when needed. You change the build configuration to 
RELEASE, optamize the application and deploy you application on a shared folder in your client's network 
path. Multiple users access this application. 
After a few days you recieve notice that one user encouters an error while executing a particullar operation. 
You want to dubug the application for that one user.You want to include verbose information for the error's. 
How can you do this while not disturbing the optamizations and execution of the applications for other users. 
Chose all that apply 
A. Change the build configuration to DEBUG and compile the project. Copy the application from the debug 
folder to the user's local machine and create a shortcut to the application on the user's desktop. 
B. Copy the application from the shared network folder and deploy the application to the user's local 
machine. Create a shortcut to the application on the user's desktop. 
C. Change the .config file in the local machine and add an entry for the trace switch and set the value to 4
 D.Change the .config file in the shared network path and add an entry for the trace switch and set the value 
to 4 
E. Complie the project using /debug TRACE 
F. Complie the project using /TRACE mySwitch 4 
Answer: B,C 
105. You use Visual Studio .NET to create a employee database application for your company. Your 
application contains the following code segment (line numbers are included for reference only) 
01 foerach (Employee oEmployee in oCompany.Employees) { 
02 bSuccess = RecordsUpdate(oEmployee); 
03 } 
When you debug your application, you discover that RecordsUpdate sometimes returns a value of False. As 
quikly as possible, you need to debug your application and find all instances where RecordsUpdate returns 
this value. What sould you do? 
A. Set a breakpoint on line 1. Step trhough code after breakpoint is reached. 
B. Set a breakpoint on line 2. Step trhough code after breakpoint is reached. 
C. Set a breakpoint on line 1. Set its condition property to !bSuccess and select the Has changed option. 
D. Set a breakpoint on line 2. Set its condition property to bSuccess and select the Is true option. 
E. Set a breakpoint on line 2. Set its condition property to !bSuccess and select the Is true option. 
F. Add a watch expression for bSuccess. Select the option Break when value is true. 
Ans. E 
106. Another developer creates data files by using a computer that runs a version of Microsoft Windows XP 
Professional distributed in France. This files contain financial transaction information, including dates, times, 
and monetary values. The data is stored in a culture specific format. You develop an application that uses 
this data files. You must ensure that your application correctly interprets all the data, regardless of the 
culture settings of the client operating system. Which code segment sould you add to your application? 
A. using System.Threading; 
using System.Data; 
Thread.CurrentThread.CurrentCulture = new CultureInfo("fr-FR"); 

B. using System.Threading; 
using System.Data; 
Thread.CurrentThread.CurrentCulture = new TextInfo("fr-FR"); 

C. using System.Threading; 
using System.Globalization; 
Thread.CurrentThread.CurrentCulture = new CultureInfo("fr-FR"); 

D. using System.Threading; 
using System.Globalization; 
Thread.CurrentThread.CurrentCulture = new TextInfo("fr-FR"); 
Ans. C 
107. You develop a windows-based application to manage business contacts. The application retrieves a list 
of contacts from a central database. The list is managed locally in a DataSet object named listDataSet, and 
it is displayed in a DataGrid control. You create a procedure that will conduct a search after you enter a 
combination of personal name and family name. Your application currently includes the following code 
segment: 
DataView dv = new DataView(); 
int i; 
dv.Table = listDataSet.Tables(0); 
dv.Sort = "FamilyName, PersonalName"; 
DataGrid1.DataSource = dv; 
You need to search for a contact whose personal name is Fukiko and whose family name is Ogisu. Which 
code segment should you use? 
A. object [] values = {"Ogisu","Fukiku"}; i = dv.Find (values); DataGrid1.CurrentRowIndex = i; 
B. object [] values = {"Ogisu,Fukiku"}; i = dv.Find (values); DataGrid1.CurrentRowIndex = i; 
C. object [] values = {"Fukiku","Ogisu"}; i = dv.Find (values); DataGrid1.CurrentRowIndex = i; 
D. object [] values = {"Fukiku,Ogisu"}; i = dv.Find (values); DataGrid1.CurrentRowIndex = i; 
Ans. A 
108. You develop a application that generates random numbers to test statistical data. The application uses 
the following code segment: 
Random rnd = new Random(); 
Short num1 = Convert.ToInt16(rnd.Next(35000)); 
Short num2 = Convert.ToInt16(rnd.Next(35000)); 
Short num3 = (num1/num2); 
When you test your application, you discover that certain exceptions are sometimes raised by this code. You 
need to write additional code that will handle all such exceptions. You want to accomplish this goal by writing 
the minimum amount of code. 
Which segment code sould you use? 
A. try { // existing code goes here } 
catch (DivideByZeroException e){ // Insert error-handling code here } 
catch (OverflowException e){ // Insert error-handling code here } 
catch (NotFiniteNumberException e){ // Insert error-handling code here } 

B. try { // existing code goes here } 
catch (ArithmeticException e){ // Insert error-handling code here } 

C. try { // existing code goes here } 
catch (DivideByZeroException e){ // Insert error-handling code here } 
catch (OverflowException e){ // Insert error-handling code here } 

D. try { // existing code goes here } 
catch (OverflowException e){ // Insert error-handling code here } 
Ans. B 

109. Catch exceptions using fewest codes... 
Try{ intX=Convert.ToInt32(lngX); intY=intX/intZero; } 
A. Catch(ArithmeticException ex){} 
B. Catch(DivideByZeroException ex){} 
C. Catch(OverflowException ex){} 
D. Catch(OverflowException ex){} Catch(DivideByZeroException ex){} Catch(Exception ex){} 
Answer:A 
(ArithmeticException is parent of DivideByZeroException & OverflowException, for just catch error,catch 
ArithmeticException using fewest code) 
111. class IEmployee{ method_employee(){}; }
class IExecutive:IEmployee{ method_executive(){}; } 
If you need to define a person as an executive, what code should be inlcuded? 
A. class Person : IExecutive 
B. class Person : IExecutive,IEmployee 
C. class Person : IEmployee,IExecutive 
D. class Person : IEmployee
E. method_employee(){}; 
F. method_executive(){}; 
Answer: A.E.F 
113. You use Visual Studio .NET to develop a Windows-based application named Advocate Resource 
Assistant (ARA). ARA contains a class named Client. The client class is defined by the following code 
segment:
Namespace Fabrikam.Buslayer 
Public Class Client 
 
Public Function GetPhone(clientID As Integer) As String 
'More code goes here. 
End Function 
 
'Other functions go here. 
End Class 
End NameSpace
The Client class is invoked from ARA by using the following code segment:
Public Class ClientForm 
Inherits System.Windows.Forms.Form 
Private Sub SetPhoneNumber(ByVal PostalCode As String) 
Dim client as New Client() 
TextBox1.Text = client.GetPhone(postalCode) 
End Sub 
End Class 
 
When you try to build your project, you receive the following error message: "Type 'Client' is not defined." 
What are two possible ways to correct this problem? (Each correct answer presents a complete solution. 
Choose two.) 
A. Fully qualify the Client class with the Fabrikam.BusLayer namespace. 
B. Fully qualify the Client class with ARA namespace. 
C. Import the Fabrikam.BusLayer namespace in the ClientForm class. 
D. Inherit the Fabrikam.BusLayer namespace in the ClientForm class. 
E. Declare the client object variable by using the WithEvents keyword. 
F. Declare the client object variable by using the Implements keyword. 
Answer: A, C 
Explanation: A: We could use a fully qualified name; Fabrikam.Buslayer.Client C: We could import the 
Fabrikam.BusLayer namespace by creating an alias: Imports client = Fabrikam.Buslayer.Client Reference: 
Visual Basic Language Concepts, Namespaces 
114. You develop a Windows-based application. Its users will view and edit employee attendance data. The 
application uses a DataSet object named customDataSet to maintain the data while users are working 
with it.
After a user edits data, business rule validation must be performed by a middle-tier component named 
myComponent. You must ensure that your application sends only edited data rows from customDataSet 
to myComponent.
Which code segment should you use? 
A. Dim changeDataSet As New DataSet 
If customDataSet.HasChanges _ 
Then myComponent.Validate(changeDataSet)
 
B. Dim changeDataSet As New DataSet 
If customDataSet.HasChanges _ 
Then myComponent.Validate(customDataSet)
 
C. Dim changeDataSet AS DataSet = customDataSet.GetChanges() 
myComponent.Validate(changeDataSet)
 
D. Dim changeDataSet As DataSet = customDataSet.GetChanges() 
myComponent.Validate(customDataSet)
 
Answer: C
Explanation: DataSet.GetChanges method gets a copy of the DataSet containing all changes made to it 
since it was last loaded, or since AcceptChanges was called. It is used to create a second DataSet that 
features only the changes to the data. We then validate the changes, the changedDataSet. Reference: .NET 
Framework Class Library, DataSet.GetChanges Method [Visual Basic] .NET Framework Class Library, 
DataSet Class [Visual Basic] Incorrect Answers A, B: We should create a dataset which contains only the 
changes. D: We should validate only the changes, not the whole dataset customerDataSet. 
115. Your company standardizes on the .NET Framework as its software development 
platform. Subsequently, virus attacks cause your company to prohibit the execution of any applications 
downloaded from the Internet. 
You must ensure that all client computers on your intranet can execute all .NET applications originating 
from your company. You must also ensure that the execution of .NET applications downloaded from the 
Internet is prohibited. You must expend the minimum amount of administrative effort to achieve your 
goal. 
Which policy should you modify?
 A. Application Domain. 
B. Enterprise 
C.Machine 
D. User 
Answer: B 
Explanation: An Enterprise policy applies to the whole domain of the company. It would require minimal 
administrative effort to set up. Reference: .NET Framework Developer's Guide Security Policy 
Administration Overview Incorrect Answers: A: An Application Domain policy is defined by the runtime host 
(any application that hosts the common language runtime) for setting load-time policy. This level cannot be 
administered. C: A machine policy only applies to a single machine. D: A user policy only applies to a single 
user. 
116. You create a user control named ScrollControl, which you plan to sell to developers. You want to 
ensure that ScrollControl can be used only by developers who purchase a license to use it. You decide to 
use a license provider implemented by the LicFileLicenseProvider class. Now you need to add code to 
ScrollControl to test for a valid control license. Which two code segments should you add? (Each correct 
answer presents part of the solution. Choose two)
 
A. < LicenseProvider(GetType(LicFileLicenseProvider))>
 
B. < LicenseProvider(GetType(ScrollControl))>
 
C. In the Load event handler for ScrollControl, place the following code segment: 
Try 
LicenseManager.Validate(GetType(ScrollControl)) 
Catch ex As Exception 
'Insert code to disallow use. 
End Try
 
D. In the Load event handler for ScrollControl, place the following code segment: 
Try 
Dim ControlLicense As License 
ControlLicense = _ 
LicenseManager.Validate(GetType(ScrollControl), Me) 
Catch ex As Exception 
'Insert code to disallow use. 
End Try
 
E. In the Load event handler for ScrollControl, place the following code segment: 
Try 
Dim bLicensed As Boolean 
bLicensed = _ 
LicenseManager.IsValid(GetType(ScrollControl)) 
Catch ex As Exception 
'Insert code to disallow use. 
End Try
 
F. In the Load event handler for ScrollControl, place the following code segment: 
Try 
Dim bLicensed As Boolean 
Dim ControlLicense As License 
bLicensed = _ 
LicenseManager.IsValid(GetType(ScrollControl),Me, _ 
ControlLicense) 
Catch ex As Exception 
'Insert code to disallow use. 
End Try
 
Answer: A, D 
Explanation: To enable licensing for your component 1. Apply a LicenseProviderAttribute to the 
LicFileLicenseProvider class. This is A). 2. Call LicenseManager.Validate or LicenseManager.IsValid in the 
constructor. This is D). A: When you create a component that you want to license, you must specify the 
LicenseProvider by marking the component with a LicenseProviderAttribute. This is accomplished by: D: 
LicenseManager.Validate produces a license. The correct code to handle this is: Dim ControlLicense As 
License ControlLicense = LicenseManager.Validate(GetType(ScrollControl), Me) Reference: .NET 
Framework Developer's Guide, Licensing Components and Controls [Visual Basic] .NET Framework Class 
Library, LicenseProviderAttribute Class [Visual Basic] Incorrect Answers B: The LicFileLicenseProvider 
class, not ScrollControl class must be used. C: The result of LicenseManager.Validate must be caught in a 
license variable. E, F: The result of LicenseManager.Validate must be caught in a license variable, not a 
Boolean variable 
117. 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. Dim c As DataColumn 
For Each C in ds.Tables("employee").Columns 
c ColumnMapping = MappingType.Attribute 
Next
 
D. Dim c As DataColumn 
For Each c In ds.Tables("employee").Columns 
c ColumnMapping = MappingType.Element 
Next
 
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 [Visual Basic] NET Framework Class 
Library. DataSet.WriteXml Method [Visual Basic] Incorrect Answers All the other proposed solutions are 
inadequate since they would produce a tagged output: 3 Paul 29 
118. You are developing a Windows-based application that logs hours worked by your employees. Your 
design goals require you to maximize application performance and minimize impact on server resources. 
You need to implement a SqlCommand object that will send a SQL INSERT action query to a database 
each time a user makes a new entry. To create a function named LineltemInser, you write the following 
code: (Line numbers are included for reference only.)
 
01 Function LineItemInsert(ByVal empid As Integer, _ 
02 ByVal projectID As Integer, ByVal hrs As Decimal, _ 
03 ByVal cnn As SqlConnection) As Integer 
04 Dim SQL As String 
05 Dim Ret As Integer 
06 SQL = "INSERT INTO TimeEntries " & _ 
07 "(EmpID, ProjectID, Hours) VALUES " & _ 
08 "(" & empID & projectID & ", " & hrs & ") " 
09 Dim cmd As New SqlCommand(SQL, cnn) 
10 
11 'Insert new code. 
12 
13 End Function
 
Your code must execute the SQL INSERT action query and verify the number of database records that 
are affected by the query. 
Which code segment should you add on line 11? 
A. cnn.Open() 
Ret = Cmd.ExecuteNonQuery() 
cnn.Close() 
Return Ret
 
B. cnn.Open() 
Ret = cmd.ExecuteScalar() 
cnn.Close() 
Return Ret
 
C. Dim reader as SqlDataReader 
cnn.Open() 
reader = cmd.ExecuteReader() 
cnn.Close() 
Return reader.RecordsAffected
 
D. Dim reader As SqlDataReader 
cnn.Open() 
reader = cmd.ExecuteReader() 
cnn.Close() 
Return reader.GetValue()
 
Answer: A 
Explanation: The SqlCommand.ExecuteNonQuery Method Executes a Transact-SQL statement against the 
Connection and returns the number of rows affected. This is the most effective solution. Reference: .NET 
Framework Class Library, SqlCommand.ExecuteNonQuery Method [Visual Basic] .NET Framework Class 
Library, SqlCommand.ExecuteScalar Method [Visual Basic] .NET Framework Class Library, SqlDataReader 
Class [Visual Basic] .NET Framework Class Library, SqlDataReader.RecordsAffected Property [Visual 
Basic] Incorrect Answers B: The SqlCommand.ExecuteScalar method executes the query, and returns the 
first column of the first row in the resultset returned by the query. Extra columns or rows are ignored. C: 
There is no need use the ExecuteReader() method. Note: The SqlDataReader.RecordsAffected property 
gets the number of rows changed, inserted, or deleted by execution of the Transact-SQL statement. D: 
There is no need use the ExecuteReader() method. 
119. You use Visual Studio .NET to develop a Windows-based application. You implement security by using 
the security classes of the .NET Framework. Your application includes the following procedure. (Line 
numbers are included for reference only)
 
01 Public Sub ApproveVacation(ByVal user 1 As String, - 
02 ByVal role1 As string, ByVal, user 2 As String, _ 
03 ByVal role2 As String) 
04 Dim PrincipalPerm1 As _ 
05 New PrincipalPermission(user1, role1) 
06 Dim principalPerm2 As _ 
07 New PrincipalPermission(user2, role2) 
08 'Insert new code. 
09 'Additional procedure code goes here 
10 End Sub
 
You must ensure that both User1 and User2 are members of the same security roles. Which code segment 
should you insert on line 8?
 
A. principalPerm1.IsUnrestricted 
principalPerm2.IsUnrestricted
 
B. principalPerm1.IsSubSetOf(principalPerm2)
 
C. principalPerm1.Intersect(principalPerm2).Demand()
 
D. principalPerm1.Union(principalPerm2).Demand()
 
Answer: B
 Explanation: The IsSubsetOf method returns true only if the identities and roles match exactly (or one of 
them are NULL). Reference: .NET Framework Developer's Guide, Combining PrincipalPermission Objects 
[Visual Basic] Incorrect Answers A: We must compare the PrincipalPermission objects with each other. C: 
The Intersect method, used to intersect two PrincipalPermission objects, return a PrincipalPermission 
object that represents the identity and role common to the intersected objects. D: Performing a union 
operation on two PrincipalPermission objects can be useful when you want to 
compactly represent a set of conditions that you want to test. This is not the case here however. 
120. You use Visual Basic .NET to develop a Windows-based application. You plan to reuse a procedure 
written in Visual Basic 6.0. The procedure includes the following array declaration: 
 
Dim Employees(1 to 10) As String 
 
You copy and paste the array declaration from the Visual Basic 6.0 project into the new Visual Basic 
.NET project. Now you must ensure that the Employees array will compile in the Visual Basic .NET 
application. 
What should you do? 
A. Include the Option Base 1 statement in the Declaration section of the module. 
B. Include the Option Base 0 statement in the Declaration section of the module. 
C. Replace the Dim statement with the following code segment: 
Dim Employees(0 to 9) As String 
D. Replace the Dim statement with the following code segment: 
Dim Employees(9) As String E. After the Dim statement, add the following code segment: 
ReDim Employees(0 to 9) As String F. After the Dim statement, add the following code segment: 
ReDim Employees(9) As String
Answer: D 
Explanation: Array lower bounds is supported in Visual Basic 6.0, but not in Visual Basic .Net. Reference: 
Visual Basic Language Reference, Dim Statement 
121. You develop a Windows-based application to manage business contacts. The application retrieves a 
list of 
contacts from a central database called RetailDB. 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 be displayed in a DataGrid control. 
Which code segment should you use? 
 
A. Dim dv As New DataView() 
With dv 
.Table = contactDataSet.Tables(0) 
.RowFilter = TextBox1.Text 
End With 
DataGrid1.DataSource = dv
 
B. Dim dv As New DataView() 
With dv 
.Table = contactDataSet.Tables(0) 
.RowFilter = "City = '" & TextBox1.Text & "'" 
End With 
DataGrid1.DataSource = dv
 
C. Dim dv As New DataView() 
With dv 
.Table = contactDataSet.Tables(0) 
.Sort = TextBox1.Text 
End With 
DataGrid1.DataSource = dv
 
D. Dim dv As New DataView() 
With dv 
.Table = contactDataSet.Tables(0) 
.Sort = "city = '" & TextBox1.Text & "'" 
End With 
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 [Visual Basic] 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. 
122. You use Visual Studio .NET to develop applications for your human resources department. You create 
the following interfaces: 
 
Public Interface IEmployee 
Property Salary() As Double 
End Interface 
Public Interface IExecutive 
Inherits IEmployee 
Property AnnualBonus() As Double 
End Interface 
 
 
The IEmployee interface represents a generic Employee concept. All actual employees in your company 
should be represented by interfaces that are derived from IEmployee. Now you need to create a class 
named Managed to represent executives in your company. You want to create this class by using the 
minimum amount of code. You write the following code: 
 
Public Class Manager 
End class 
Which additional code segment or segments should you include in Manager? (Choose all that apply) 
A. Implements IExecutive 
B. Implements IEmployee, IExecutive 
C. Inherits IExecutive 
D. Inherits IEmployee, IExecutive 
E. Property Salary() As Double Implements IExecutive.Salary 
F. Property AnnualBonus() As Double Implements _ IExecutive.AnnualBonus 
Answer: A, E, F A: A class can implement an Interface. The Manager class should implement the IExecutive 
interface. E, F: The properties that are defined in the Interface must be implemented in a Class. Incorrect 
Answers B: The class should not implement both Interfaces, just the IExecutive interface. C, D: A class 
cannot inherit from an Interface. 
Explanation: The Manager Class only needs to inherit from the IExecutive class. The Manager class inherits 
the AnnualBonus property from the IExecutie class and the Salary property from the IEmployee class (since 
IExecutive inherits from IEmployee). There is no need to define any properties for the new class. Reference: 
Visual Basic Language Concepts, Inheritance Basics 
123. You develop a Windows-based application that includes the following code segment. (Line numbers 
are included for reference only.) 
 
01 Public Sub password_Validating (ByVal sender As _ 
02 Object, ByVal e As _ 
03 System.ComponentModel.CancelEventArgs) 
04 Handles password.Validating 
05 If ValidPassword() = False Then 
06 'Insert new code. 
07 End If 
08 End Sub 
 
You must ensure that users cannot move control focus away from textPassword if 
ValidPassword returns a value of False. You will add the required code on line 6. 
Which code segment should you use? 
A. e.Cancel = True 
B. sender = textName 
C. password.AcceptsTab = False 
D. password.CausesValidation =False 
Answer: A 
Explanation: We cancel the validation of the control. 
Incorrect Answers B: This assignment does not make much sense. C: Does not apply. D: Setting 
Causevalidation to False would disable the Validate event. This will not prevent the focus to moved away 
from the control. 
124. You develop a Windows-based application that contains a class named Contact. Contact contains an 
event named ContactSaved. Many Contact objects will be created from the Contact class and inserted into 
an array named Contacts. You create a custom method named HandleContactSaved in your application. 
You must ensure that your application calls HandleContactSaved whenever the ContactSaved event is fired 
for any of the Contact objects. What should you do? 
A. Use the WithEvents keyword to declare each Contact object. 
Add each Contact object to the Contacts array as it is created.
 
B. Add each Contact object to the Contacts array as it is created. 
Add the Handles keyword to HandleContactSaved.
 
C. Add each Contact object to the Contacts array as it is created. 
Assign HandleContactSaved to the Handle property of the HandleRef structure.
 
D. Add each Contact Object to the Contacts array as it is created. 
Call the AddHandler statement and pass the new Contact object and the address of HandleContactSaved.
 Answer: D 
Explanation: The standard way to create an event handler is to use the Handles keyword with the 
WithEvents keyword. You can use the AddHandler statement to dynamically connect events with event 
handler procedures. To handle events using AddHandler 1. Declare an object variable of the class that is the 
source of the events you want to handle. 2. Use the AddHandler statement to specify the name of the event 
sender, and the AddressOf statement to provide the name of your event handler. Reference: Visual Basic 
Language Concepts, Writing Event Handlers Incorrect Answers A: We would have to use a Handles clause 
for the HandleContactSaved method as well. Only declaring WithEvents is not sufficient. B: The Handles 
keyword is used to declare that a procedure handles a specified event. We must however specify the event. 
C: This proposed solution does not work. 
125. You use Visual Studio .NET to create an application. Your application contains two classes, Region 
and City, which are defined in the following code segment. (Line numbers are included for reference only.) 
 
01 Public Class Region 
02 Public Overridable Sub CalculateTax() 
03 'Code to calculate tax goes here. 
04 End Sub 
05 End Class 
06 Public Class City 
07 Inherits Region 
08 Public Overrides Sub CalculateTax() 
09 'Insert new code. 
10 End Sub 
11 End Class 
You need to add code to the CalculateTax method of the City class to call the CalculateTax method of the 
Region class. 
Which code segment should you add on line 9? 
A. CalculateTax() 
B. Me.CalculateTax() 
C. MyBase.CalculateTax() 
D. MyClass.CalculateTax()
Answer: C 
Explanation: The MyBase keyword to call methods in a base class when overriding methods in a derived 
class. Reference: Visual Basic Language Concepts, Inheritance Basics Visual Basic Language 
Specification, 4.5.1 Overriding Methods 
126. You are maintaining a Visual Studio .Net application that was developed by a colleague The application 
calculates interest and penalties for financial transactions. All variables that contain financial data are 
defined as type Double. When users enter financial data, the application periodically fails during execution. 
Failure occurs in response to a variety of actions. The application returns the following error message: 
"Arithmetic operation resulted in an overflow" You need to identify as many potential exceptions as possible 
in the application code. What should you do? 
A. Set Option Explicit to On. 
B. Set Option Explicit to Off. 
C. Set Option Strict to On. 
D. Set Option Strict to Off. 
E. Set Option Compare to Binary. 
F. Set Option Compare to Text. 
Answer: C 
Explanation: The Options Strict statement concerns which conversion are allowed. Option Strict ON 
disallows any data type conversions in which data loss would occur and any conversion between numeric 
types and strings. In short it help to identify potential arithmetic exceptions. Reference: Visual Basic 
Language Reference, Option Strict Statement Visual Basic Compiler Options, /optionexplicit Visual Basic 
Language Reference, Option Compare Statement Incorrect Answers A: The /optionexplicit causes the 
compiler to report errors if variables are not declared prior to use. It would not help finding potential 
exceptions however. B: Disabling variable declaration checking will not help finding exceptions. D: Setting 
Options Strict to Off disables type conversion checks. We should enable these checks. E, F: The Option 
Compare statement is used at file level to declare the default comparison method to use when string data is 
compared. This setting would not help finding exceptions. 
127. Your development team uses Visual Studio .NET to create an accounting application, which contains a 
class named RetailAccounts. 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 RetailAccounts is terminated. 
What should you do? 
A. Add code to the Terminate event of RetailAccounts to call the ShutDownObject method of each 
COM component class. 
B. Find each location in your code where a reference to RetailAccounts is set to Nothing or goes out of 
scope. Add code after each instance to manually invoke the Visual Studio .NET garbage collector. 
C. Add the procedure Protected Overrides Finalize()to RetailAccounts. Add code to the 
procedure to call the ShutDownObject method of each COM component class. 
D. Add the procedure Private Sub Finally()to RetailAccounts. Add code to the procedure to 
call the ShutDownObject method of each COM component class. 
Answer: C 
Explanation: The Sub Finalize procedure in Visual Basic .NET is a destructor and it destroys objects. It could 
be useful when destroying Visual Basic 6.0 COM objects. Reference: Visual Basic Language Concepts, 
Object Lifetime: How Objects Are Created and Destroyed 
128. You use Visual Studio .NET to create a Windows-based data management application named MyApp. 
You implement the following code segment: 
 
Dim oSwitch As New_ 
TraceSwitch("MySwitch", "My TraceSwitch") 
Dim oWriter As New 
IO.StreamWritter(IO.File.Open("c:\MyApp.txt", _ 
IO.FileMode.Append)) 
Dim oListener As New _ 
TextWriterTraceListener(oWriter) 
 
Trace.Listeners.Add(oListener) 
Try 
CustomerUpdate() 
Catch oEx As Exception 
Trace.WriteLineIf(oSwitch.TraceError, _ 
"Error: " & oEx.Message) 
Finally 
Trace.Listeners.Clear() 
oWriter.Close() 
oWriter. = Nothing 
End Try 
 
You compile a debug version of the application and deploy it to a user's computer. The user reports errors, 
which are generated within the CustomerUpdate procedure. You decide to enable logging of the error 
messages generated by CustomerUpdate. You want to use the minimum amount of administrative effort. 
What should you do? 
A. Start the application with the following command line: /TRACE MySwitch 1. 
B. Start the application with the following command line: /d:TRACE=True. 
C. Start the application with the following command line: /XML 
D. Create an environment variable on the user's computer. Name the variable MySwitch and assign it a 
value of 1. 
E. Edit your application's config file to set the value of MySwitch to 1. 
Answer: E 
Explanation: After your application has been distributed, you can still enable or disable trace output by 
configuring the trace switches in your application. You can change the values of the switch objects using the 
configuration file. In addition to specifying the name of a switch to configure, you must also specify a value 
for the switch. This value is an Integer. For BooleanSwitch, a value of 0 corresponds to Off, and any nonzero 
value corresponds to On. Reference: Visual Basic and Visual C# Concepts, Trace Switches Visual Basic 
and Visual C# Concepts, Configuring Trace Switches 
129. You use Visual Studio .NET to create a component named Request. This component includes a 
method named AcceptRequest, which tries to process new user requests for services. AcceptRequest 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 AcceptRequest: 
Me.Validate()
 
B. Use the following code segment in AcceptRequest: 
Try 
Me.Validate() 
Catch ex As Exception 
Throw ex 
End Try
 
C. Use the following code segment in AcceptRequest: 
Try 
Me.Validate() 
Catch ex As Exception 
Throw new Exception ("Exception in AcceptRequest", ex) 
End Try
 
D. Create a customer Exception class named RequestException by the following code segment: 
Public Class RequestException 
Inherits System.ApplicationException 
Public Sub New() 
End Sub 
Public Sub New (message As String) 
MyBase.New(message) 
End Sub 
Public Sub New (message As String, inner As Exception) 
MyBase.New(message, inner) 
End Sub 
End class 
 
In addition, use the following code segment in AcceptRequest: 
Try 
Me.Validate() 
Catch ex As Exception 
Throw new RequestException("Exception in _ 
AcceptRequest", ex) 
End Try
 
Answer: B 
Explanation: We use a Try...Catch statement to catch any exceptions from the Validate function. We then 
throw any exceptions, without adding any further information (not C), to the parent form of Request. 
Reference: Visual Basic and Visual C# Concepts, Throwing Exceptions from Components 
130. You use Visual Studio .NET to develop a data entry form for a Windows-based application. The form 
will display one record at a time from a database. The form must include four Button controls. Each control 
will be used to navigate through the data in the database. You decide to create one procedure to handle the 
Click event for all four controls. What should you do? 
 
A. Create a control array consisting of four Button controls. 
Your code will inspect the Index argument that is passed into the Click event.
 
B. Create a control array consisting of four Button controls. 
Your code will inspect the Index property of the sender parameter of the Click event.
 
C. Create four individual Button controls. 
Create a procedure named NavButtons_Click to handle the Click event for all four controls by using the 
AddHandler keyword. 
D. Create four individual Button controls. 
Create a procedure named NavButtons_Click to handle the Click event for all four controls by using the 
Implements keyword. 
Answer: C 
Explanation: The AddHandler statement is similar to the Handles clause in that both allow you to specify an 
event handler that will handle an event. We can use the AddHandler statement to add the four events to the 
event handler, the NavButtons_clock procedure. Reference: Visual Basic Language Concepts, AddHandler 
and RemoveHandler Visual Basic Concepts, Control Array Changes in Visual Basic .NET Visual Basic 
Language Concepts, Implements Keyword Incorrect Answers A, B: Control arrays could be used in Visual 
Basic 6.0, but they are no longer supported in Visual Basic .NET. D: The Implements keyword is used to 
signify that a class member implements a specific interface. We should not implement an interface in this 
scenario however. We want to configure events for an event handler. 
131. You use Visual Studio .NET to develop a Windows-based application. You implement the security 
classes of the .NET Framework. 
As users interact with your application, role-based validation will frequently be performed. You must ensure 
that only validated Windows NT or Windows 2000 domain users are permitted to access your application. 
You add the appropriate Imports statements for the System.Security.Principal namespace and the 
System.Threading namespace. 
Which additional code segment should you use? 
 
A. AppDomian.CurrentDomain.SetPrincipalPolicy( _PrincipalPolicy.WindowsPrincipal) 
Dim principal As WindowsPrincipal = CType(Thread.CurrentPrincipal, WindowsPrincipal)
 
B. AppDomain.CurrentDomain.SetThreadPrincipal( _PrincipalPolicy.WindowsPrincipal) 
Dim principal As WindowsPrincipal = _CType(Thread.CurrentPrincipal, WindowsPrincipal)
 
C. Dim identity As WindowsIdentity =WindowsIdentity.GetCurrent() 
Dim principal As New WindowsPrincipal(identity)
 
D. Dim identity As WindowsIdentity = _WindowsIdentity.GetAnonymous() 
Dim principal As New WindowsPrincipal(identity) 
Answer: A 
Explanation: The WindowsPrincipal Class allows code to check the Windows group membership of a 
Windows user. In particular we can check if the user belongs to domain users group. Furthermore, the 
SetPrincipalPolicy method specifies how principal and identity objects should be attached to a thread 
Reference: .NET Framework Class Library, WindowsPrincipal Class [Visual Basic] .NET Framework Class 
Library, WindowsIdentity Class [Visual Basic] Incorrect Answers B: We should use the SetPrincipalPolicy 
method, not the SetThreadPrincipal Method. Note: The AppDomain.SetThreadPrincipal Method sets the 
default principal object to be attached to threads C: WindowsIdentity Class represents a Windows user. The 
GetCurrent method is used to create a WindowsIdentity object that represents the current user. However, 
we must the WindowsPrincipal class to test if the users are valid domain users. D: The 
WindowsIdentity.GetAnonymous Method returns a WindowsIdentity object that represents an anonymous 
Windows user. This will not help in validating the current user. 
132. You develop a Windows-based application for your payroll department. The application will include a 
procedure named Signin, which must allow users to report that they are present in their offices. The 
procedure must also allow each user to sign in other users. The procedure must return a Boolean variable 
indicating success or failure. In most cases, the procedure will be called with no parameters. When no 
parameters are passed in, the procedure should recognize the user by the information stored in global 
variables. When one user signs in another user, the procedure should accept a string variable parameter 
that represents the user name of the user who is signed in. You want to define your procedure to present the 
most efficient contract to the consumer. Which two code segments should you use? (Each correct answer 
presents part of the solution. Choose two) 
 
A. Public Function SignIn() As Boolean. 
B. Public Function SignIn(userName As String) As Boolean 
C. Public Function SignIn(userName As String, _Success As Boolean) As Boolean 
D. Public Function SignInWithName(userName As String) _As Boolean 
E. Public SignIn(username As String) 
F. Public Sub SignInWithName(userName As String) 
Answer: A, B 
Explanation: We must overload the definition of Signin. We should implement Signin as functions, not as sub 
procedures, since we want Signin to return a value. A: One Signin function with no parameters. B: One 
Signin function with a string parameter. Reference: Visual Basic Language Specification, Overloading and 
Signatures Incorrect Answers C: The function should only have one parameter, not two. D: When 
overloading we must identical named identities. E, F: Functions is better in this scenario. Furthermore to 
overload a Sub procedure we need at least two Sub procedures with the same name. 
133. You develop a Windows-based application that will retrieve employee vacation data and display it in a 
DataGrid control. The data is managed locally in a DataSet object named employeeDataSet. You need to 
write code that will enable users to sort data by department. 
Which code segment should you use? 
 
A. Dim dvDept As New DataView() 
dvDept.Table = employeeDataSet.Tables(0) 
dvDept.Sort = "ASC" 
DataGrid1.DataSource = dvDept
 
B. Dim dvDept As New DataView() 
dvDept.Table = employeeDataSet.Tables(0) 
dvDept.Sort = "Department" 
DataGrid1.DataSource = dvDept
 
C. Dim dvDept As New DataView() 
dvDept.Table = employeeDataSet.Tables(0) 
dvDept.ApplyDefaultSort = True 
DataGrid1.DataSource = dvDept
 
D. Dim dvDept As New DataView() 
dvDept.Table = employeeDataSet.Tables(0) 
dvDept.ApplyDefaultSort = False 
DataGrid1.DataSource = dvDept
 
Answer: B
 Explanation: The DataView.Sort Property gets or sets the sort column or columns. The sort string contains 
the column name followed by "ASC" (ascending) or "DESC" (descending). Columns are sorted ascending by 
default. Multiple columns can be separated by commas. The dvDept.Sort = "Department" assignment sorts 
the view on the Department column. Reference: .NET Framework Class Library, DataView.Sort Property 
[Visual Basic] Incorrect Answers A: We must specify the column name, not just the sort order. C: We don't 
want to use the default sort. We want to sort on the Department column. D: Disabling the default sort will not 
sort on the Department column. 
134. You develop a Windows control named FormattedTextBox, which will be used by many developers in 
your company. FormattedTextBox will be updated frequently. 
You create a custom bitmap image named CustomControl.bmp to represent FormattedTextBox in the Visual 
Studio .NET toolbox. The bitmap contains the current version number of the control, and it will be updated 
each time the control is updated. The bitmap will be stored in the application folder. If the bitmap is not 
available, the standard TextBox control bitmap must be displayed instead. 
Which class attribute should you add to FormattedTextBox? 
A. < ToolboxBitmap(GetType(TextBox))< _Class FormattedTextBox
 
B. < ToolboxBitmap("CustomControl.bmp")> _Class FormattedTextBox
 
C. < ToolboxBitmap(GetType(TextBox), _" CustomControl.bmp")> _Class FormattedTextBox
 
D. < ToolboxBitmap(GetType(TextBox))> _< ToolboxBitmap("CustomControl.bmp")> _Class 
FormattedTextBox
 
Answer: C 
Explanation: We specify the standard Textbox control bitmap with (GetType(TextBox). Then we supply the 
file name of the custom bitmap image. Reference: Visual Basic and Visual C# Concepts, Providing a 
Toolbox Bitmap for Your Control .NET Framework Class Library, ToolboxBitmapAttribute Class [Visual 
Basic] Incorrect Answers A: We must use the CustomControl.bmp bitmap image. B: We must specify the 
default image with GetType(TextBox) D: Incorrect syntax. 
135. You plan to use Visual Studio .NET to create a class named BusinessRules, which will be used by all 
applications in your company. BusinessRules defines business rules and performs calculations based on 
those rules. Other developers in your company must not be able to override the functions and subroutines 
defined in BusinessRules with their own definitions. Which two actions should you take to create 
BusinessRules? (Each correct answer presents part of the solution. Choose two) 
 
A. Create a Windows control library prokect 
B. Create a class library project. 
C. Create a Windows Service project. 
D. Use the following code segment to define BusinessRules: Protected Class BusinessRules
 
E. Use the following code segment to define BusinessRules: Public Shadows Class BusinessRules
 
F. Use the following code segment to define BusinessRules: Public NotInheritable Class BusinessRules
 
G. Use the following code segment to define BusinessRules: Public MustInherit Class BusinessRules
 
Answer: B, F 
Explanation: B: A class library project would be adequate for an implementation of Business Rules. F: A 
NotInheritable class is a class that may not be derived from. NotInheritable classes are primarily used to 
prevent unintended derivation. Reference: Visual Basic Language Reference, Class Statement Visual Basic 
Language Specification, MustInherit and NotInheritable Classes Visual Basic Language Concepts, 
Introduction to Objects in Visual Basic Visual Basic Language Concepts, Overriding Properties and Methods 
Incorrect Answers A: The BusinessRules Class defines business rules and perform calculations. It does not 
define a user Interface. A Windows control library project is not appropriate. C: Business rules are not 
implemented as a Windows service. D: Entities declared with the Protected keyword have protected access. 
They are accessible only from within their own class or from a derived class. However, this would not 
prevent the class from being overridden. E: Shadowing does not apply here. Shadowed members are used 
to locally replace a member that has broader scope. G: The MustInherit class forces the regular class to 
include actual implementations of all inherited MustInherit members which is what we want to prevent. 
136. You develop a Windows-based application that accesses a Microsoft SQL Server database. The 
application includes a form named CustomerForm, which contains a Button control named SortButton. The 
database includes a table named Customers. Data from Customers will be displayed on CustomerForm by 
means of a DataGrid control named DataGrid1. The following code segment is used to fill DataGrid1: 
 
Private Sub FillDataGrid() 
Dim oConn As New SqlConnection(MyConString) 
Dim oDA As New SqlDataAdapter( _ 
"SELECT CustomerID, CompanyName, ContactName, " & _ 
"Phone FROM Customers", oConn) 
Dim oDS As New DataSet() 
oDA.MissingSchemaAction = MissingSchemaAction.AddWithKey 
oDA.Fill(oDS, "Customers") 
Dim oDV As New DataView(oDS.Tables("Customers")) 
oDV.Sort = "CustomerName ASC, ContactName ASC" 
oDV.ApplyDefaultSort = True 
DataGrod1.DataSource = oDV 
End Sub 
 
The primary key for Customers is the CustomerID column. You must ensure that the data will be displayed 
in ascending order by primary key when the user selects SortButton. 
What should you do? 
 
A. Set the Sort property of the DataView object to an empty string. 
B. Set the ApplyDefaultSort property of the DataView object to False. 
C. Include an ORDER BY clause in the SELECT statement when you create the DataAdapter object. 
D. Set the RowFilter property of the DataView object to CustomerID. 
Answer: A 
Explanation: You can use the ApplyDefaultSort property to automatically create a sort order, in ascending 
order, based on the primary key column or columns of the table. ApplyDefaultSort only applies when the 
Sort property is a null reference or an empty string, and when the table has a primary key defined. All 
requirements are met:  The ApplyDefaultSort is set to true (see code above).  The Table has a primary key 
 The Sort property is set to the empty string. The DataView will be sorted in ascending order on the Primary 
Key column. 
Incorrect Answers B: We want to use the default sort order. We should keep the value of ApplyDefaultSort 
property set to True. C: It is not necessary to include a ORDER BY clause in the SELECT statement. D: We 
want to sort the DataView, not to filter it. 
137. You develop a Windows-based application named Payroll. Your application receives information in the 
form of an XML data file named dataFile. This file does not include any schema information. You need to 
write code to load the XML data into a DataSet object. 
Which code segment should you use? 
 
A. Dim ds As New DataSet("PayrollData") 
ds.readXml(dataFile, _ 
XmlReadMode.IgnoreSchema)
 
B. Dim ds As New DataSet("PayrollData") 
ds.readXml(dataFile, 
XmlReadMode.InferSchema)
 
C. Dim ds As New DataSet("PayrollData") 
ds.readXml(dataFile, _ 
XmlReadMode.ReadSchema)
 
D. Dim ds As New DataSet("PayrollData") 
ds.readXml(dataFile, _XmlReadMode.Fragment)
Answer: B 
Explanation: XmlReadMode InferSchema ignores any inline schema, infers schema from the data and loads 
the data. Reference: .NET Framework Class Library, XmlReadMode Enumeration [Visual Basic] .NET 
Framework Class Library, DataSet.ReadXml Method (String, XmlReadMode) [Visual Basic] Incorrect 
Answers A: XmlReadMode IgnoreSchema ignores any inline schema and reads data into the existing 
DataSet schema. We do not have any schema here however. C: XmlReadMode ReadSchema reads any 
inline schema and loads the data. There is no inline schema however. D: XmlReadMode Fragment is not 
used with a datafile. It reads XML documents, such as those generated by executing FOR XML queries, 
against an instance of SQL Server. 
138. 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 error-handling 
code to your application to capture detailed information about any stored procedure that causes an error. 
Which code segment should you use? 
 
A. Try 
RetailConnection.Open() 
Catch e As Exception 
'Insert error-handling code. 
End Try
 
B. Try 
RetailConnection.Open() 
Catch e As SqlException 
'Insert error-handling code. 
End Try
 
C. Try 
RetailConnection.Open() 
Catch e As DataException 
'Insert error-handling code. 
End try
 
D. Try 
RetailConnection.Open() 
Catch e As DBConcurrencyException 
'Insert error-handling code. 
End Try 
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 [Visual Basic] 
139. You use Visual Studio .NET to develop a Windows-based application for your human resources (HR) 
department. The HR department has two subdivisions named Benefits and Employee Information. The 
Benefits subdivision includes the Vacation group. Both subdivisions will use your application. You plan to 
create four forms modeled after the organizational structure of the HR department. The forms will be named 
HR, EmployeeInformation, Benefits, and Vacation. 
 
The forms must be arranged in a hierarchy so that each form includes all code and controls found on the 
forms above it in the hierarchy. The form at the top of the hierarchy will be a standard Windows Form. The 
form must also adhere to the following rules: 
 
 All forms should include code to access the general HR database. 
 Only forms used by the Benefits subdivision should have access to the Benefits database table. 
 The forms used by the Employee Information subdivision should have access to the 
EmployeeInformation database table. 
 The forms used by the Vacation group should include custom code to calculate vacation time. 
Now you must create the form hierarchy. 
Which code segment should you use? 
 
A. Public Class HR 
Inherits System.Windows.Forms.Form 
End Class 
Public Class Benefits 
Inherits System.Windows.Forms.Form 
Implements HR 
End Class 
Public Class Vacation 
Inherits System.Windows.Forms.Form 
Implements Benefits 
End Class 
Public Class EmployeeInformation 
Inherits System.Windows.Forms.Form 
Implements HR 
End Class
 
B. Public Class HR 
Inherits System.Windows.Forms.Form 
End Class 
Public Class Benefits 
Inherits System.Windows.Forms.Form 
Implements HR 
End Class 
Public Class Vacation 
Inherits System.Windows.Forms.Form 
Implements Benefits 
End Class 
Public Class EmployeeInformation 
Inherits System.Windows.Forms.Form 
Implements Benefits 
End Class
 
C. Public Class HR 
Inherits System.Windows.Forms.Form 
End Class 
Public Class Benefits 
Inherits HR 
End Class 
Public Class Vacation 
Inherits Benefits 
End Class 
Public Class EmployeeInformation 
Inherits HR 
End Class
 
D. Public Class Hr 
Inherits System.Windows.Forms.Form 
End Class 
Public Class Benefits 
Inherits HR 
End Class 
Public Class Vacation 
Inherits Benefits 
End Class 
Public Class EmployeeInformation 
Inherits Benefits 
End Class
 
Answer: C 
Explanation: To meet the required restrictions on the Benefits database table, the EmployeeInformation 
table, and the custom code, we must use the Inherits statement: 1) HR inherits from the root form 2) 
Benefits inherits from HR. 3) Vacation inherits from Benefits. 4) EmployeeInformation inherits from HR. The 
requirements are met:  All forms should include code to access the general HR database. Is met by the fact 
that all forms inherits from HR.  Only forms used by the Benefits subdivision should have access to the 
Benefits database table. Is met by the fact that nothing inherits from Benefits.  The forms used by the 
Employee Information subdivision should have access to the EmployeeInformation database table. This is 
possible since EmployeeInformation is a separate Class.  The forms used by the Vacation group should 
include custom code to calculate vacation time. This is possible since EmployeeInformation is a separate 
Class. Reference: Visual Basic Language Specification, Inheritance Visual Basic Language Reference, 
Implements Statement Incorrect Answers A: The implements keyword can only be used for interfaces. We 
cannot use like provided in this proposed solution. B: The implements keyword can only be used for 
interfaces D: EmployeeInformation should inherit from HR, not from Benefits. 
140. Your development team creates an order entry application by using Visual Studio .NET. The application 
stores and retrieves data in a Microsoft SQL Server database. All database connections in the application 
are centralized in class variables within a class named MyDataClass. 
Each time your application needs to access data from the database, it creates an instance of MyDataClass 
by using the following code segment: 
 
Dim oData As New MyDataClass() 
 
When the oData variable is no longer needed, it is set to Nothing or goes out of scope. 
Initially, about 500 sales representatives use the application. Later, your company hires 50 new sales 
representatives who also use the application. You discover that the database is running out of available 
connections because of the increases usage. 
You must ensure that database connections are released immediately when they are no longer needed. You 
must also maintain an optimum level of application performance. 
What should you do? 
 
A. Add the procedure Protected Overrides Finalize() to My DataClass. 
Write code in the procedure to close all open database connections. 
B. Add the procedure Private Sub Finally() to MyDataClass. 
Write the code in the procedure to close all open database connections. 
C. Implement the IDisposable interface within My DataClass.  
Write code in the Dispose procedure of 
IDisposable to close all open database connections. 
Call the Dispose method of MyDataClass before any reference to MyDataClass is set to Nothing 
or goes of scope. 
D. Find each location in your code where a reference to MyDataClass is set to nothing or goes out of Scope. 
Add code after each instance to manually invoke the Visual Studio .NET garbage collector. 
E. Add code to the Terminate event of MyDataClass to close all open database connections. F. Ensure that 
each reference to MyDataClass is set to Nothing before it goes of scope. 
Answer: A 
Explanation: The Object.Finalize Method allows an Object to attempt to free resources and perform other 
cleanup operations before the Object is reclaimed by garbage collection. By adding code that closes all 
open database connections for this method of the class, we would ensure that all connections would be 
released. Reference: .NET Framework Class Library, Object.Finalize Method Visual Basic Language 
Concepts, Object Lifetime: How Objects Are Created and Destroyed Incorrect Answers B: There is no 
method called Finally. C: This is a possible solution. However, it is not the most straightforward or effective 
solution. D: Calling the garbage collection frequently would increase overhead. E: The Terminate event was 
used in Visual Basic 6.0. It has been replaced by the Finalize method. F: Setting the instances of the class 
to nothing would not close the database connectdions. 
141. You use Visual Studio .NET to create a data entry form. The form enables users to edit personal 
information such as address and telephone number, The form contains a text box named textPhoneNumber. 
If a user enters an invalid telephone number, the form must notify the user of the error. You create a function 
named ValidPhone that validates the telephone number entered. You include an ErrorProvider control 
named ErrorProvider1 in your form. 
Which additional code segment should you use? 
 
A. Private Sub textPhone_Validating _ 
(ByVal sender As Object, _ 
ByVal e As System.ComponentModel.CancelEventArgs) _ 
Handles textPhoneNumber.Validating 
If ValidPhone() = False then _ 
ErrorProvider1.SetError(textPhone, "Invalid Phone. ") 
End If 
End Sub
 
B. Private Sub textPhone_Validated _ 
(ByVal sender As Object, _ 
ByVal e As System.EventArgs) _ 
Handles textPhoneNumber.Validated 
If ValidPhone() = False then _ 
ErrorProvider1.SetError(textPhone, "Invalid Phone.") 
End If 
End Sub
 
C. Private Sub textPhone_Validating _ 
(ByVal sender As Object, _ 
ByVal e As System.ComponentModel.CancelEventArgs) _ 
Handles textPhoneNumber.Validating 
If ValidPhone() = False then _ 
ErrorProvider1.GetError(textPhone) 
End IF 
End Sub
 
D. Private Sub textPhone_Validated _ 
(ByVal sender As Object, _ 
ByVal e As System.EventArgs) _ 
Handles textPhoneNumber.Validated 
If ValidPhone() = False then _ 
ErrorProvider1.GetError(textPhone) 
End If 
End Sub
 
E. Private Sun textPhone_Validating _ 
(ByVal sender As Object, _ 
ByVal e As System.ComponentModel.CancelEventArgs) _ 
Handles textPhoneNumber.Validating 
If ValidPhone() = False then _ 
ErrorProvider1.UpdateBinding() 
End If 
End Sub
 
F. Private Sub textPhone_Validated _ 
(ByVal sender As Object, _ 
ByVal e As System.EventArgs) _ 
Handles textPhoneNumber.Validated 
If ValidPhone() = False then _ 
ErrorProvider1.UpdateBinding() 
End If 
End Sub 
Answer: A 
Explanation: We should add code for the Validating Event. If the ValidPhone() function evaluates to false we 
should use the ErrorProvider.SetError method to set the error description string. Note: Focus events occur in 
the following order: 1. Enter 2. GotFocus 3. Leave 4. Validating 5. Validated 6. LostFocus Reference: .NET 
Framework Class Library, Control.Validating Event [Visual Basic] .NET Framework Class Library, 
ErrorProvider Members.NET Framework Class Library, Control.Validated Event [Visual Basic] Incorrect 
Answers B, D, G: We should add code for the Validating Event, not the Validated event. The 
Control.Validated Event occurs when the control is finished validating. C: The ErrorProvider.Geterror method 
returns the current error description string for the specified control. We want to set it however. F: The 
ErrorProvider.Updatebinding method is of no use here. It provides a method to update the bindings of the 
DataSource, DataMember, and the error text. We only want to set the error description string. 
142. You develop a Windows-based application. You plan to use ADO.NET to call a Microsoft SQL Server 
stored procedure named EmployeeData. This procedure accepts a parameter for querying the database by 
an employee's family name. 
You need to add code to your application to set up the parameter for use with the stored procedure. Which 
three lines of code should you add? (Each correct answer presents part of the solution. Choose three.) 
 
A. Dim parm1 As New SqlParameter() 
B. Dim parm1 As New SqlParameter("@FamilyName", _Sq1DbType.VarChar) 
C. parm1.Direction = ParameterDirection.Input 
D. parm1.Direction = ParameterDirection.InputOutput 
E. cmd.Parameters.Add(parm1) 
F. parm1.Add(cmd) 
Answer: B, C, E 
Explanation: B: The names of the parameter added must match the names of the parameter markers in your 
stored procedure. C: The parameter is used as an input parameter. E: We add the parameter to the 
command. Reference: .NET Framework Class Library, SqlParameter Class [Visual Basic] .NET Framework 
Class Library, SqlParameter Members .NET Framework Class Library, SqlParameter Constructor () [Visual 
Basic] .NET Framework Class Library, SqlParameter Constructor (String, SqlDbType) [Visual Basic] 
Incorrect Answers A: We should specify the name of the parameter and its value. D: The parameter is an 
input parameter, not an input/output parameter. F: The parameter should be added to the command, not 
vice versa. 
143. You need to create an OleDbCommand object to retrieve information about postal codes for your 
mailing list application. You create an OleDbConnection object named conn. You need to instantiate the 
OleDBCommand object and set the CommandText and Connection properties. 
What are two possible code segments for you to use? (Each correct answer presents a complete solution. 
Choose two) 
 
A. Dim comm As New OleDbCommand() 
comm.CommandText = "SELECT * FROM Regions" 
comm.Connection = conn
 
B. Dim comm. As New OleDbCommand("sp_GetRegions", conn) 
comm.CommandType = CommandType.Text
 
C. Dim comm As New OleDbCommand("SELECT * FROM Regions", _conn) 
comm.CommandType = CommandType.Text
 
D. Dim comm As New OleDbCommand("sp_GetRegions", conn) 
comm.CommandType = CommandType.TableDirect
 
E. Dim comm As New OleDbCommand() 
comm.CommandType = "SELECT * FROM Regions" 
comm.Connection = conn
 
Answer: A, C 
Explanation: A: The CommandText property of the OleDBCommand gets or sets the SQL statement or 
stored procedure to execute at the data source. The Connection property of the OleDBCommand gets or 
sets the OleDbConnection used by this instance of the OleDbCommand. C: An OleDbCommand object is 
created correctly. The CommandType is set to Text which matches the SQL statement in the 
OleDBCommand object. Reference: .NET Framework Class Library, OleDbCommand Class [Visual Basic] 
.NET Framework Class Library, OleDbCommand Members .NET Framework Class Library, CommandType 
Enumeration [Visual Basic] Incorrect Answers B: We cannot use the Text CommandType if we want to 
execute a stored procedure. The StoredProcedure CommandType should be used instead. D: The 
StoredProcedure, not the TableDirect, CommandType should be used if we want to use a stored procecure 
in the command string. E: The CommandType property of OleDBCommand gets or sets a value indicating 
how the CommandText property is interpreted. It cannot be used to set the SQL Statement of the command. 
144. You use Visual Studio .NET to develop a Windows-based application that contains a single form. This 
form contains a Label control named labelBDValue and a TextBox control named textBDValue. 
labelBDValue displays a caption that identifies the purpose of textBDValue. 
You want to write code that enables users to place focus in textBDValue when they press ALT+V. This key 
combination should be identified to users in the display of labelBDValue. 
Which three actions should you take? (Each correct answer presents part of the solution. Choose three) 
 
A. Set labelBDValue.UseMnemonic to True. 
B. Set labelBDValue.Text to "&Value". 
C. Set labelBDValue.CausesValidation to True. 
D. Set textBDValue.CausesValidation to True. 
E. Set textBDValue.TabIndex to exactly one number less than labelValue.TabIndex. 
F. Set textBDValue.TabIndex to exactly one number more than labelValue.TabIndex. 
G. Set textBDValue.Location so that textValue overlaps with labelValue on the screen. 
H. Add the following code to the Load event of MainForm: text.Value.Controls.Add (labelValue);
 Answer: A, B, F 
Explanation: If the UseMnemonic property is set to true (A) and a mnemonic character (a character 
preceded by the ampersand) is defined in the Text property of the Label (B), pressing ALT+ the mnemonic 
character sets the focus to the control that follows the Label in the tab order (F). You can use this property to 
provide proper keyboard navigation to the controls on your form. Note1 The UseMnemonic property gets or 
sets a value indicating whether the control interprets an ampersand character (&) in the control's Text 
property to be an access key prefix character. UseMnemonic is set to True by default. Note 2: As a practice 
verify the answer yourself. Reference: NET Framework Class Library, Label.UseMnemonic Property [Visual 
Basic] Incorrect Answers C, D: The CausesValidation setting has no effect in this scenario. E: The Text 
control must use a tabindex that is the successor to the tabindex of the label control. G, H: This is not 
necessary. It has no effect here. 
145. You use Visual Studio .NET to create an application named RetailClient. Another developer in your 
company creates a component named RetailComponent. Your application uses namespaces exposed by 
RetailComponent. 
You must deploy both RetailClient and RetailComponent to several computers in your company's 
accounting department. You must also ensure that RetailComponent 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 RetailClient and RetailComponent 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 
RetailComponent to the new folder.
 B. Deploy RetailClient and RetailComponent 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 RetailClient.exe.config and add a privatePath tag that points to the folder where RetailComponent is 
located.
 C. Deploy RetailClient and RetailComponent to separate folders on each client computer. 
In each client application that will use RetailComponent, add the following code segment: using 
RetailComponent;
 D. Deploy RetailClient and RetailComponent 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 RetailComponent. 
E. Deploy RetailClient and Tes BDumpsComponent to separate folders on each client computer. 
Register RetailComponent on each client computer by using the RegSvr32 utility.
 F. Deploy RetailClient and RetailComponent to separate folders on each client computer. 
Add RetailComponent to the global assembly cache. 
Answer: A, D, F 
Explanation: A: XCOPY deployment of the RetailComponent, 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 RetailComponent. 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..: 
146. You develop a Windows-based application that stores and retrieves data in a Microsoft SQL Server 
database called RetailSales. Your application uses ADO.NET and the SqlClient managed provider. You 
need to identify the severity level of all errors returned from SQL Server. What should your errorhandling 
code do? 
 
A. Catch the SqlException that is thrown when the error occurs and access the Source property. 
B. Catch the SqlException that is thrown when the error occurs and access the Class property. 
C. Examine the State property of the SqlConnection object for the status of the connection after the error 
occurs. 
D. Examine the DataSource property of the SqlConnection object for the status of the connection after the 
error occurs.
 Answer: B
 Explanation: The Class property of the SQLException class gets the severity level of the error returned from 
the SQL Server .NET Data Provider. Reference: .NET Framework Class Library, SqlException Class [Visual 
Basic] .NET Framework Class Library, SqlException Members .NET Framework Class Library, 
SqlConnection Members Incorrect Answers A: The Source property of the SQLException class gets the 
name of the provider that generated the error. C: The State property of the SQLConnection object only gets 
the current state of the connection. D: The DataSource property of the SQLConnection object only gets the 
name of the instance of SQL Server to which to connect. 
147. You develop an application, RetailRemote, that enables mobile salespeople to look up contact 
information in a database. The salespeople use portable computers running Windows XP Professional. 
Because of the large size of the database, you want to create a distribution package to distribute your 
application and the database on a CD-ROM. However, you discover that the total size of the distribution 
package exceeds the capacity of a 650-MB CD-ROM. You want to reduce the size of the distribution 
package so it will fit on a single CD-ROM. 
Which two actions should you take? (Each correct answer presents part of the solution. Choose two) 
A. Exclude the .NET Framework dependency from your distribution package.
 B. Use a third-party compression utility to compress the .NET Framework dependency files.
 C. Set the package files option of your setup project to In cabinet file(s) and set the maximum CAB file size 
to 650 MB. 
D. Set the Compression property of your setup project to Optimized for size. 
E. Set the Bootstrapper property of your setup project to None.
 Answer: A, D 
Explanation: A: The Windows XP operating system includes the .NET Framework already. We can safely 
exclude it from the distribution package. The size o Note: The .NET Framework merge module is 
automatically added as a dependency for any application built with the .NET Framework. You should 
exclude the merge module only if you are sure that the application will only be installed where the .NET 
Framework run-time files are already installed. D: If you choose Optimized For Size, the setup project will be 
the smallest possible size, but might require more time to install. Reference: 70-306/70-316 Training kit, 
Deploying your Application, Bootstrapper, Compression, Page 475-476 Visual Studio, Build, Configuration 
Settings, Deployment Project Properties Dialog Box Visual Studio, Walkthrough: Reducing the Size of an 
Installer by Excluding Merge Modules Incorrect Answers B: Third party compression utilities are not used to 
compress Visual Studio .NET projects. C: A maximum cab size of 650MB would enable spanning the 
application to several CDs. However, we want the application to fit on a single CD. E: The Bootstrapper 
property specifies whether a bootstrapper (bootstrapping application) will be included in an installer. A 
bootstrapper includes the files needed to install Microsoft Windows Installer 1.5 on the target computer if it is 
not already installed. Windows installer 1.5 is already included in Windows XP but is required for earlier 
operating systems. Setting the Bootstrapper property to None would reduce the project size. However, not 
as much as A) or D). 
148. You develop a Windows-based application RetailApp that includes several menus. Every top-level 
menu contains several menu items, and certain menus contain items that are mutually exclusive. You 
decide to distinguish the single most important item in each menu by changing its caption text to bold type. 
What should you do? 
 
A. Set the DefaultItem property to True. 
B. Set the Text property to "True". 
C. Set the Checked property to True.
 D. Set the OwnerDraw property to True. 
Answer: A 
Explanation: Gets or sets a value indicating whether the menu item is the default menu item. The default 
menu item for a menu is boldfaced. Reference: .NET Framework Class Library, MenuItem.DefaultItem 
Property [Visual Basic] Incorrect Answers B: The Text property contains the text that is associated with the 
control. We cannot format this text by HTML-like tags in the text. C: We don't want the menu-item to be 
selected, just bold. D: When the OwnerDraw property is set to true, you need to handle all drawing of the 
menu item. You can use this capability to create your own special menu displays. 
149. You use Visual Studio .NET to develop a Windows-based application. The application includes several 
menu controls that provide access to most of the application's functionality. 
One menu option is named calculateOption. When a user chooses this option, the application will perform a 
series of calculations based on information previously entered by the user. 
To provide user assistance, you create a TextBox control named RetailHelp. The corresponding text box 
must display help information when the user pauses on the menu option with a mouse or navigates to the 
option by using the arrow keys. 
You need to add the following code segment: 
 
RetailHelp.Text = "This menu option calculates the result.."; 
In which event should you add this code segment? 
 
A. calculateOption_Click 
B. calculateOption_Popup
 C. calculateOption_Select 
D. calculateOption_DrawItem 
E. calculateOption_MeasureItem
 Answer: C
Explanation: The Select event is raised when a menu item is highlighted. We should use the Select event to 
set the helper text. Reference: 70-306/70-316 Training kit, Using Menu Item Events, Page 79 Incorrect 
Answers A: The Click event occurs when a menu item is selected. B: The Popup event is raised just before 
a menu item's list of menu items is displayed. It can be used to enable and disable menu items at run time 
before the menu is displayed. D: The DrawItem event handler provides a Graphics object that enables you 
to perform drawing and other graphical operations on the surface of the menu item. E: The MeasureItem 
event occurs when the menu needs to know the size of a menu item before drawing it. 
150. You use Visual Studio .NET to develop a Windows-based application that will interact with a Microsof 
t SQL Server database. Your application will display employee information from a table named 
RetailEmployees. You use ADO.NET to access the data from the database. 
To limit the possibility of errors, you must ensure that any type of mismatch errors between your 
application code and the database are caught at compile time rather than at run time. 
Which two actions should you take? (Each correct answer presents part of the solution. Choose two)
 A. Create an XML schema for RetailEmployees.
 B. Create an XML style sheet for RetailEmployees.
 C. Create an XML namespace for RetailEmployees.
 D. Create a typed DataSet object based on the XML schema. 
E. Create a typed DataSet object based on the XML style sheet. 
F. Create a TypeDelegator class based on the XML namespace. 
Answer: A, D
 Explanation: A: We need to create an XML schema that describes the structure of the data. : From this XML 
schema we can create a typed DataSet object. Incorrect Answers B, E: There is no such thing as an XML 
style sheet. C: Namespaces are used to enable shorthand notation of objects. It does not apply here. F: 
Delegates are used for the managed code objects to encapsulate method calls. TypeDelagators do not 
apply here. 

