Chapter 18. Sample Test 2

Question 1

You're developing a customer contactmanagement application using Visual Studio .NET. You use the methods of the Trace and Debug classes to log serious error messages encountered during program execution. You want to record all such errors in the Windows Event Log. You do not want any duplicate entries for error messages in the Event Log. In what ways can you add a listener to the Windows Event Log? [Select two.]

  • A.

     Dim traceListener As EventLogTraceListener = _    New EventLogTraceListener("CustomEventLog") Trace.Listeners.Add(traceListener) 
  • B.

     Dim traceListener As EventLogTraceListener = _    New EventLogTraceListener("CustomEventLog") Trace.Listeners.Add(traceListener) Debug.Listeners.Add(traceListener) 
  • C.

     Dim traceListener As EventLogTraceListener = _    New EventLogTraceListener("CustomEventLog") 
  • D.

     Dim traceListener As EventLogTraceListener = _    New EventLogTraceListener("CustomEventLog") Debug.Listeners.Add(traceListener) 
Question 2

You're developing a supplier-evaluation system using Visual Studio .NET. While testing the program, you notice that the value of the TotalShipments variable sometimes becomes zero and causes an exception in the CalculateAvgShipDelay method. You want your program to check the value of TotalShipments variable and display an error message when the value of TotalShipments is zero. You want the program to display this error message regardless of how you compile the program. Which of the following code segments should you write before making a call to the CalculateAvgShipDelay method?

  • A.

     Trace.Assert(TotalShipment = 0, "TotalShipments is_ zero") 
  • B.

     Trace.Assert(TotalShipment <> 0, "TotalShipments is_ zero") 
  • C.

     Debug.Assert(TotalShipment = 0, "TotalShipments is_ zero") 
  • D.

     Debug.Assert(TotalShipment <> 0, "TotalShipments is_ zero") 
Question 3

Your application includes a DataSet object that contains a DataTable object named Suppliers. This DataTable object contains all rows from the Suppliers table in your database. You want to bind an object to a DataGrid control on a form such that the DataGrid control displays only the suppliers from Michigan. You want a quick solution. What should you do?

  • A. Create a filtered array by calling the DataTable.Select method on the Suppliers data table and bind the array to the DataGrid control.

  • B. Create a new SqlCommand object to retrieve only suppliers from Michigan. Use a new SqlDataAdapter object to fill a new DataSet object with these suppliers. Bind the new DataSet object to the DataGrid control.

  • C. Use a For Each loop to move through the entire Suppliers data table. Each time a DataRow object that represents a supplier from Michigan is found, that DataRow object is bound to the DataGrid control.

  • D. Create a filtered DataView object from the Suppliers data table and bind the DataView object to the DataGrid control.

Question 4

You're developing a Windows-based application that displays supplier data in a DataGrid control. The supplier data is stored in table named Suppliers within the dsSuppliers DataSet object. The primary key for the Suppliers table is the SupplierID column. You need to display the supplier data in the DataGrid control in ascending order of the primary key. You write the following code segment to accomplish this task:

 Dim dvSuppliers As DataView =  _     New DataView(dsSuppliers.Tables("Suppliers")) dvSuppliers.Sort = "ASC" dvSuppliers.ApplyDefaultSort = True dataGrid1.DataSource = dvSuppliers 

However, when you run the program, the results are not what you expected. How should you change the preceding code segment to get the intended results?

  • 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. Set the RowFilter property of the DataView object to SupplierID.

  • D. The code segment is correct; you need to ensure that the data in the Suppliers table is already sorted on the primary key.

Question 5

You are developing a Windows-based application using Visual Basic .NET. Your application's configuration files have the following code:

 <system.diagnostics>     <switches>         <add name="TraceLevelSwitch" value="3" />     </switches> </system.diagnostics> 

You have written the following tracing code in your program:

 Dim ts As TraceSwitch = New TraceSwitch( _  "TraceLevelSwitch", "Trace the application") <Conditional("DEBUG")> _ Private Sub Method1()     Trace.WriteLineIf(ts.TraceError, _      "Message 1", "Message 2") End Sub <Conditional("TRACE")> _ Private Sub Method2()     Trace.WriteLine("Message 3") End Sub Private Sub btnCalculate_Click( _  ByVal sender As System.Object, _  ByVal e As System.EventArgs) Handles btnCalculate.Click     If ts.TraceWarning Then         Trace.WriteLine("Message 10")         Method1()     Else         Trace.WriteLineIf(ts.TraceInfo, "Message 20")         Method2()     End If     If (ts.TraceError) Then         Trace.WriteLineIf(ts.TraceInfo, "Message 30")         Trace.WriteLineIf(ts.TraceVerbose, "Message 40")     End If End Sub 

What tracing output will be generated when you run your program in debug mode and click the btnCalculate button?

  • A.

     Message 10 Message 1 Message 2 Message 30 
  • B.

     Message 10 Message 2: Message 1 Message 30 
  • C.

     Message 10 Message 2 Message 30 Message 40 
  • D.

     Message 20 Message 3 Message 30 Message 40 
Question 6

You use Visual Basic .NET to create an assembly named Tracker.dll , which contains classes for tracking a shipment and is used by several applications, including both managed applications and unmanaged COM applications. The COM applications are already compiled and use late binding to invoke methods from the assembly. What actions should you take to ensure that the assembly is properly deployed on the target machine? [Select all that apply.]

  • A. Create a strong name for the assembly by using the Strong Name tool ( sn.exe ).

  • B. Register the assembly using the Assembly Registration tool ( regasm.exe ).

  • C. Create a type library for the application using the Type Library Exporter tool ( tlbexp.exe ).

  • D. Import the COM type library definition into an assembly by using the Type Library Importer tool ( tlbimp.exe ).

  • E. Deploy the assembly to the Global Assembly Cache (GAC).

  • F. Deploy the assembly to the application's installation directory.

  • G. Deploy the assembly to the Windows system directory.

Question 7

You use Visual Basic .NET to develop an assembly that allows developers to create pie charts in their applications. You name the assembly PieChart.dll and package it as version 1.0.0 for distribution over the Internet. After two months, you discover a bug in the assembly. You fix the bug by releasing a new version 1.0.1 of the assembly. You do not want other developers to recompile the applications they built using version 1.0.0 of PieChart.dll . You want to make sure that when version 1.0.1 of PieChart.dll is deployed, all existing applications that use version 1.0.0 now start using version 1.0.1 of the assembly. You want to minimize efforts in deploying the new version of the assembly. Which of the following steps should you take to deploy version 1.0.1 of PieChart.dll ?

  • A. Modify the application-configuration files of all the applications that use version 1.0.0 of the PieChart.dll assembly to now use version 1.0.1 of the PieChart.dll assembly.

  • B. Modify the machine-configuration files to redirect the references for version 1.0.0 of the PieChart.dll assembly to version 1.0.1 of the PieChart.dll assembly.

  • C. Deploy a publisher policy file to redirect the references for version 1.0.0 of the PieChart.dll assembly to version 1.0.1 of the PieChart.dll assembly.

  • D. Remove version 1.0.0 of the PieChart.dll assembly and then deploy version 1.0.1 of the PieChart.dll assembly.

Question 8

You develop desktop applications for a large university. Your new project is to write a Visual Basic .NET application that allows professors to maintain the test scores of students. You place a DataGrid control on the Windows form and bind the data grid to a DataView object. You allow professors to make changes in the data grid by adding new rows, by modifying existing rows, and by deleting existing rows. You now want to place a command button that allows professors to view the deleted rows from the original data. How should you program the Click event of this command button?

  • A. In the event handler for the Click event, set the RowFilter property of the DataView object to DataViewRowState.Deleted .

  • B. In the event handler for the Click event, set the RowFilter property of the DataView object to DataViewRowState.OriginalRows .

  • C. In the event handler for the Click event, set the RowStateFilter property of the DataView object to DataViewRowState.Deleted .

  • D. In the event handler for the Click event, set the RowStateFilter property of the DataView object to DataViewRowState.OriginalRows .

Question 9

You need to debug a Windows application by using Visual Studio .NET installed on your local machine. The Windows application is deployed on a remote server. When you attempt to debug the application, you get a DCOM configuration error. Which of the following steps should you take to resolve this problem?

  • A. Add your account to the Power Users group on the local computer.

  • B. Add your account to the Power Users group on the remote computer.

  • C. Add your account to the Debugger Users group on the local computer.

  • D. Add your account to the Debugger Users group on the remote computer.

Question 10

You're developing a Windows Forms application that displays a background image in a form. Your application needs to comply with the Windows logo program. In order to do so, you want your application to monitor for changes to the HighContrast setting at runtime so that it can remove a background image from a form if necessary. Which event must you trap?

  • A. SystemEvents.UserPreferenceChanged

  • B. Form.Paint

  • C. SystemEvents.PaletteChanged

  • D. Form.Load

Question 11

You're developing a Windows Forms application using Visual Basic .NET. A TextBox control on your Windows form should accept no more than three characters from the user . However, your code may need to place the value "Invalid" in the TextBox control. What value should you use for the MaxLength property of this control?

  • A. 3

  • B. 4

  • C. 7

  • D. 8

Question 12

You have created an array of Project objects named aProjects. Each Project object has a Name property and a Number property. You want to display all the Name values in a ListBox control named lbProjects. Which code snippet should you use for this purpose?

  • A.

     lbProjects.DataSource = aProjects lbProjects.ValueMember = Name 
  • B.

     lbProjects.DataSource = aProjects lbProjects.DisplayMember = Name 
  • C.

     lbProjects.DataSource = aProjects lbProjects.ValueMember = "Name" 
  • D.

     lbProjects.DataSource = aProjects lbProjects.DisplayMember = "Name" 
Question 13

You have created a custom component for your application that monitors a bidirectional parallel port for error messages. This component raises an event named PortError whenever an error message is detected . At that point, you must make the error code available to the control container. You want to use the best coding practices. Which of the following options should you choose to make the error code available to the container?

  • A. Place the error code in a property of the component for the container to retrieve it.

  • B. Pass the error code as a parameter to the PortError event handler.

  • C. Define a global variable in a separate class and place the value in that variable.

  • D. Define a custom PortErrorEventArgs class that inherits from the EventArgs class to contain the error code and then pass an instance of the class as a parameter to the PortError event handler.

Question 14

You are developing a Windows Forms application that allows the users to create network diagrams. You plan to use objects from the System.Drawing namespace to draw shapes on a form at runtime. You have already determined that you will draw these shapes during the form's Paint event. You want to write minimal code. How should you create the Graphics object required by the classes of the System.Drawing namespace?

  • A. Call the CreateGraphics method of the form.

  • B. Retrieve the Graphics property of the PaintEventArgs object that is passed to the event.

  • C. Pass the handle of the form to the Graphics.FromHwnd method.

  • D. Call the CreateGraphics method of the control that has the focus.

Question 15

You use Visual Basic .NET to create a Windows Forms application. You create a form called Form1 and set its BackColor property set to Red. You add a new form called Form2 to the application by using Visual Inheritance to derive the new form from Form1. You set Form2 to be the startup object for the application, and you set its BackColor property to Blue. After this, you change the BackColor property of Form1 to Yellow. When you run the application, what is the BackColor value of Form2?

  • A. Blue

  • B. Red

  • C. Yellow

  • D. Control

Question 16

You are creating a graphics application that will manipulate a variety of image formats. You have created an OpenFileDialog object in your program and have set its Filter property as follows :

 ofdPicture.Filter="Image Files (BMP, GIF, JPEG, etc.)" & _     "*.bmp;*.gif;*.jpg;*.jpeg;*.png;*.tif;*.tiff" & _     "BMP Files (*.bmp)*.bmp" & _     "GIF Files (*.gif)*.gif" & _     "JPEG Files (*.jpg;*.jpeg)*.jpg;*.jpeg" & _     "PNG Files (*.png)*.png" & _     "TIF Files (*.tif;*.tiff)*.tif;*.tiff" & _     "All Files (*.*)*.*" 

You have created a Button control with its Text property set to "Open Image ". When you click this button, the Open File dialog box is displayed allow a selection. You want BMP files to be the default choice in the dialog box. Which of the following values for the FilterIndex property must you choose to achieve this in the event handler of the Button control's Click event?

  • A. 0

  • B. 1

  • C. 2

  • D. 3

Question 17

Your Visual Basic .NET application contains a Windows form that allows the users to delete multiple records from a database. You do not want the users to unintentionally delete the records. Therefore, you develop a form named frmConfirm to get confirmation from the users. This form includes two Button controls: btnOK and btnCancel. The DialogResult property of btnOK is set to OK, and the DialogResult property of btnCancel is set to Cancel. Which code snippet should you use to display frmConfirm and process the user's choice?

  • A.

     Dim frm As New frmConfirm() frm.ShowDialog() If frm.DialogResult = DialogResult.OK Then     ' Delete the records End If 
  • B.

     Dim frm As New frmConfirm() frm.Show() If frm.DialogResult = DialogResult.OK Then     ' Delete the records End If 
  • C.

     Dim frm As New frmConfirm() frm.ShowDialog() If frm.btnOK.DialogResult = DialogResult.OK Then     ' Delete the records End If 
  • D.

     Dim frm As New frmConfirm() frm.Show() If frm.btnOK.DialogResult = DialogResult.OK Then     ' Delete the records End If 
Question 18

You're developing a Windows Forms application that enables users to generate shipping labels. The program needs to generate thousands of shipping labels each day. You use the Trace object to monitor the application and log the results in the Windows Event Log. You need to monitor errors, warnings, and other informational messages generated by the Trace object. You should have flexibility in controlling the amount of information logged for your application, and you want to do this with minimal administrative effort. What should you do?

  • A. Start the application using the /d:TRACE switch.

  • B. Define an environment variable named TRACE and set its value to True or False. In the program, check the value of the environment variable to indicate the amount of information you want to be logged for your application.

  • C. Declare a compilation constant named TRACE and set its value to Error, Warning, or Info . In your program use #If, #Else , and #Endif directives to check for the level of tracing you want.

  • D. Use the TraceSwitch class in your program and use the TraceSwitch.Level property to check whether you need to log the performance. Set the level of the TraceSwitch by using the application's configuration file.

Question 19

While you are debugging in Visual Studio .NET, you want to watch the value of variables that are used in the current executing method. Which of the following debugger windows is the easiest window to use to watch these variables ?

  • A. Me

  • B. Autos

  • C. Locals

  • D. Watch

Question 20

You are performing final acceptance testing on your application prior to shipping it. You have set a breakpoint inside the SelectedIndexChanged event handler for a combo box. However, when you select a new value in this combo box, the code in the event handler is executed but does not stop at the breakpoint. What could be the most likely problem?

  • A. Selecting a value in a combo box does not fire the SelectedIndexChanged event.

  • B. You are executing the project using the Release configuration.

  • C. You have neglected to add the <Conditional("DEBUG")> attribute to the event handler.

  • D. You have neglected to add #Const DEBUGGING = 1 to the code.

Question 21

You are debugging a Windows Forms application that you wrote using Visual Studio .NET. Your code uses the Trace class to produce the debugging output. In which configuration(s) will this output be enabled?

  • A. In the Release configuration only.

  • B. In the Debug configuration only.

  • C. In both the Release configuration and the Debug configuration.

  • D. In neither the Release configuration nor the Debug configuration.

Question 22

You need to develop a custom toolbar control that will be used by several Windows applications to display application-specific tool buttons . You want this control to be of the same width as the form in which the control is hosted, and the control should be displayed at the top of the form. When the parent form is resized or repositioned, the custom toolbar control should also be resized and repositioned accordingly . Which of the following answers should you choose to accomplish this requirement?

  • A. Create a property that allows the developers to set the Anchor property of the custom toolbar control and then set the default value of this property to AnchorStyle.Top .

  • B. Create a property that allows the developers to set the Dock property of the custom toolbar control and then set the default value of this property to DockStyle.Top .

  • C. In the UserControl_Load event handler, add the following code:

     Me.Anchor = AnchorStyle.Top 
  • D. In the UserControl_Load event handler, add the following code:

     Me.Dock = DockStyle.Top 
Question 23

You're developing a Windows-based application using Visual Basic .NET. The application needs to display weather information for the ZIP Code entered by the user. You do not know how to determine the weather information yourself; therefore, you choose to call a Web service to provide this information in your application. You know the URL of the ASMX file published by the Web service, but you do not know any details of the Web service's interface. Which of the following actions should you take first to get information about the Web service?

  • A. Run the Web Service Discovery tool.

  • B. Open the ASMX file in a Web browser.

  • C. Run the XML Schema Definition tool.

  • D. Copy the ASMX file to your client project.

Question 24

You're creating an ASP.NET Web service project using Visual Studio .NET. The project includes a class named RefLibrary that contains this method:

 Public Function Version() As String     Version = "1.6" End Function 

You note that you are able to instantiate the RefLibrary class from a Web service client project, but the Version method is not available. What could be the problem?

  • A. Only properties can be part of the public interface of a Web service.

  • B. You must mark the method with the WebService attribute.

  • C. The methods of a Web service can only return Object data.

  • D. You must mark the method with the WebMethod attribute.

Question 25

The customer service representatives in your company often receive calls from customers inquiring about the shipping status of their orders. You have been assigned to create an application that assists the customer service representatives in easily finding the shipping status. You decide to create a Windows-based application that calls the XML Web services provided by the shipping and logistics company to retrieve the latest shipping status. While testing the application, the user of the application complains that the user interface is very slow. You find that your program is waiting for the Web service call to execute. You need to design the most efficient solution. What should you do to make your application responsive ?

  • A. Use the WaitHande.WaitAll method of the IAsyncResult.AsyncWaitHandle object.

  • B. Call the End method of the XML Web service.

  • C. Use the WaitHande.WaitAny method of the IAsyncResult.AsyncWaitHandle object.

  • D. Supply a callback delegate to the Begin method of the XML Web service. After the XML Web service returns, a thread will invoke the callback method from the thread pool.

Question 26

Your company intends to ship a text-editing application to a variety of locales, including the United States, France, Israel, China, and Japan. One of the features of the application is searching for text within longer text passages. You have been asked to implement this feature using Visual Basic .NET. What should you use to perform this search?

  • A. CultureInfo.CompareInfo

  • B. Array.Sort

  • C. String.IndexOf

  • D. String.IndexOfAny

Question 27

You've designed a Windows service application using Visual Studio .NET. The service stores information related to computer uptime and page faults. Computers in many countries will use this Windows service. When storing this information for future analysis, which culture should you use?

  • A. The invariant culture

  • B. The en-US culture

  • C. The culture specified by Thread.CurrentThread.CurrentCulture

  • D. A culture selected by the user

Question 28

Your application contains the following resource files containing string resources:

MyApp.resx

MyApp.fr.resx

MyApp.fr-FR.resx

MyApp.en.resx

MyApp.en-US.resx

The user executes the application on a computer running French (Canadian) software so that the CurrentUICulture property is set to fr-CA. What will be the result?

  • A. The resources from MyApp.fr.resx will be used.

  • B. The resources from MyApp.fr-FR.resx will be used.

  • C. The resources from MyApp.en-US.resx will be used.

  • D. An exception will be thrown.

Question 29

Your application performs various mathematical calculations. You are beginning to sell this application in multiple countries. How should you ensure that the correct numeric formatting is used in all cases?

  • A. Allow the user to select a culture from a list. Create a CultureInfo object based on the user's selection and assign it to the Thread.CurrentThread.CurrentCulture property. Then use the ToString method to format numeric amounts.

  • B. Accept the Thread.CurrentThread.CurrentCulture property as it is set when your application is run. Use the ToString method to format numeric amounts.

  • C. Prompt the user for a numeric format and store it in the Registry.

  • D. Allow the user to select a numeric format from a list of supported formats.

Question 30

You need to develop a graphics application using Visual Basic .NET. Your application needs to draw images on the screen, and you are looking for a solution that gives you the best performance. You have created several variations of a method that draws an image. Which of the following variations would you choose for your application?

  • A.

     Public Sub DrawSampleImage(ByVal e As PaintEventArgs_ )     Dim newImage As Image = Image.FromFile("SampImag.jpg")     Dim ulCorner As Point = New Point(100, 100)     e.Graphics.DrawImage(newImage, ulCorner) End Sub 
  • B.

     Public Sub DrawSampleImage(ByVal e As PaintEventArgs)     Dim newImage As Image = Image.FromFile("SampImag.jpg")     Dim x As Integer = 100     Dim y As Integer = 100     e.Graphics.DrawImage(newImage, x, y) End Sub 
  • C.

     Public Sub DrawSampleImage(ByVal e As PaintEventArgs)     Dim newImage As Image = Image.FromFile("SampImag.jpg")     Dim destRect As Rectangle = _         New Rectangle(100, 100, 450, 150)     e.Graphics.DrawImage(newImage, destRect) End Sub 
  • D.

     Public Sub DrawSampleImage(ByVal e As PaintEventArgs)     Dim newImage As Image = Image.FromFile("SampImag.jpg")     Dim x As Double = 100.0F     Dim y As Double = 100.0F     e.Graphics.DrawImage(newImage, x, y) End Sub 
Question 31

Your application requires the ability to read and write to the Windows Event Log in order to function properly. Which .NET security feature should you use to ensure that your code has this capability?

  • A. Role-based security

  • B. Code access security

  • C. Type Safety

  • D. Encryption

Question 32

Your Visual Studio .NET project contains the following API declaration:

 Declare Auto Function GetComputerName Lib "kernel32" ( _              ByVal lpBuffer As String, _              ByRef nSize As Integer) As Integer 

The project also contains code to use this API to display the computer name:

 Private Sub ShowName()     Dim buf As String = New String("")     Dim len As Integer     Dim ret As Integer     ret = GetComputerName(buf, len)     MessageBox.Show(buf.ToString) End Sub 

Users report that no computer name is displayed. What could be the problem?

  • A. The users' computers have no name set in their network properties.

  • B. You should use the StringBuilder object instead of the String object.

  • C. You failed to initialize the String object to hold the returned characters.

  • D. You should use the DllImport attribute rather than the Declare statement.

Question 33

You are responsible for maintaining a COM component that is used by numerous applications throughout your company. You are not yet ready to migrate this COM component to .NET managed code, but you need to make it available to an increasing number of other projects being developed under the .NET Framework. You want to create the most efficient solution. What should you do?

  • A. Set a direct reference to the existing COM component from each .NET project.

  • B. Use the Type Library Importer tool to create and sign an assembly that will use the COM component and then place the COM component in the Global Assembly Cache.

  • C. Obtain a Primary Interop Assembly for the COM component.

  • D. Set a direct reference from a single .NET project to the COM component and then include this project in each solution that must make use of the component.

Question 34

You are using the PrintDocument class to print a graphical banner that should span multiple printed pages. However, only the first page of the banner prints. What is the most likely cause of this problem?

  • A. You have neglected to set PrintPageEventArgs.HasMorePages to True when there are more pages to print.

  • B. You have neglected to set a sufficiently large value for PrintPageEventArgs.MarginBounds.Height .

  • C. You have neglected to set a sufficiently large value for PrintPageEventArgs.PageBounds.Height .

  • D. You have only called the Print method once rather than once per page.

Question 35

You are developing a Windows application that presents history lessons to students. Some students who use this application may have low vision. These students will use the application through a screen reader. You use a TextBox control to get the user's name. When the TextBox control gets the focus, the screen reader must be able to identify it and aid the user by speaking out the word name . Which property of the control should you configure to fulfill this requirement?

  • A. Name

  • B. Text

  • C. AccessibleName

  • D. AccessibleRole

Question 36

You use Visual Studio .NET to develop a Windows application that queries data from a SQL Server database. You use a SqlConnection object to connect to the database. As soon as the database operation is completed, you want to make sure any pending database transactions are rolled back and connection is returned to the connection pool. You need to reuse the same SqlConnection object when your program needs to query the database again. Which of the following actions should you take?

  • A. Call the Dispose method of the SqlConnection object.

  • B. Call the Finalize method of the SqlConnection object.

  • C. Call the Close method of the SqlConnection object.

  • D. Set the SqlConnection object to Nothing.

Question 37

You use Visual Studio .NET to develop a Windows-based application. Your application is used to create and maintain product catalogs. You use a DataSet object named dsCatalog to store the product data as users edit the information. When the users save the catalog, you need to store it in an XML file. The root element of the resulting XML file should be <ProductInformation> . You intend to use the DataSet.WriteXml method to save the catalog to an XML file. Which of the following statements should you use to ensure that the correct XML root element is written to the XML file?

  • A.

     dsCatalog.NameSpace = "ProductInformation" 
  • B.

     dsCatalog.Locale = "ProductInformation" 
  • C.

     dsCatalog.Prefix = "ProductInformation" 
  • D.

     dsCatalog.DataSetName = "ProductInformation" 
Question 38

You're developing a Windows-based application that allows users to view and modify recently placed orders. Your application needs to display data from the OrderHeader and OrderDetails data tables. Information from OrderHeader is displayed in a set of controls grouped together in a GroupBox control; the information from OrderDetails is displayed in a DataGrid control. Your program must ensure that as soon as a different order is selected in the GroupBox control, the DataGrid control displays the details corresponding to that order. Which of the following actions will you take to implement this functionality?

  • A. Define primary keys on the OrderHeader and OrderDetails table.

  • B. Create a foreign key constraint in the OrderDetails table.

  • C. Add a DataRelation object to the Relations collection of the DataSet object.

  • D. Use the DataSet.Merge method.

Question 39

You need to develop a Windows-based application named ProcessOrders. This application receives XML data files from various customers, reads the files, and stores them in a SQL Server database for further processing. The ProcessOrders application uses an XML schema file to define the format and data types of the XML data files. However, not all customers send the XML data file using the same schema. Your application should parse the incoming data files to ensure they conform to the XML schema. Which of the following actions should you take to accomplish this requirement?

  • A. Implement an XmlDocument object to load the document and then pass the schema file to this object to validate and parse the XML document.

  • B. Implement an XmlValidatingReader object and program an event handler for the ValidationEventHandler event to parse any data file that does not conform to the XML schema.

  • C. Read the XML file into a DataSet object and set its EnforceConstraints property to True.

  • D. Read the XML file and schema into a DataSet object and then program the DataSet.MergeFailed event handler to parse any data file that does not conform to the XML schema.

Question 40

You are developing a Windows-based application to query product information from a SQL Server database. The application specification requires that the users of your application be able to search for a product just by entering the first few characters. You store the characters entered by the user in a variable named ProdName . Which of the following SQL statements should you use to retrieve the data from the database?

  • A.

     sqlStatement = "SELECT Name, Description, Price FROM_ " & _    "Product WHERE Name IN '" & ProdName & "%'" 
  • B.

     sqlStatement = "SELECT Name, Description, Price FROM_ " & _     "Product WHERE Name LIKE '" & ProdName & "%'" 
  • C.

     sqlStatement = "SELECT Name, Description, Price FROM_ " & _     "Product WHERE Name IN '" & ProdName & "*'" 
  • D.

     sqlStatement = "SELECT Name, Description, Price FROM_ " & _     "Product WHERE Name LIKE '" & ProdName & "*'" 
Question 41

Your Visual Basic .NET application needs to read data from a SQL Server 6.5 database and write it to a flat file once every 12 hours. A legacy application accesses this file to update its data. Because the data you will read from the database is huge, you want to retrieve the data with the least impact on the server resources and optimize the performance as much as possible. Which object should you use to load the data from the database?

  • A. DataSet

  • B. DataTable

  • C. SqlDataReader

  • D. OleDbDataReader

Question 42

The assembly CalculateTax is a member of the following code groups (and only the following code groups):

Level

Code Group

Permission Set

Exclusive

LevelFinal Property

Enterprise

All Code

Everything

No

No

Enterprise

Company Code

Internet

No

No

Machine

Restricted Code

LocalIntranet

No

Yes

User

Restricted Components

Nothing

No

No

What permission does the CLR assign to the assembly CalculateTax ?

  • A. Everything

  • B. Internet

  • C. LocalIntranet

  • D. Nothing

Question 43

You allow users to edit product information on a DataGrid control that is bound to a DataSet object. When the user clicks the Update button on the form, you call the SqlDataAdapter.Update method to cause the changes from the DataSet object to persist to the underlying database. Users report that new records and updated rows are saved properly but that deleted rows are reappearing the next time they run the application. What could be the problem?

  • A. The users do not have permission to update the underlying table.

  • B. The Update method does not delete rows.

  • C. Someone is restoring an old version of the database between the two executions of the program.

  • D. You have failed to set the DeleteCommand property of the SqlDataAdapter object.

Question 44

Your Visual Basic .NET application reads an XML file from disk into an XmlDocument object; then it modifies some of the nodes in the document. You need to write minimal code. Therefore, which object should you use to write the modified XmlDocument object back to disk?

  • A. XmlTextWriter

  • B. XmlWriter

  • C. StreamWriter

  • D. BinaryWriter

  • E. TextWriter

Question 45

Your SQL Server database contains a table, Sales, with these columns :

SalesID (int, identity)

StoreNumber (int)

Sales (int)

You want to create a stored procedure that accepts as inputs the store number and sales, inserts a new row in the table with this information, and returns the new identity value. Which SQL statement should you use?

  • A.

     CREATE PROCEDURE procInsertSales   @StoreNumber int,   @Sales int,   @SalesID int AS   INSERT INTO Sales (StoreNumber, Sales)   VALUES (@StoreNumber, @Sales)   SELECT @SalesID = @@IDENTITY 
  • B.

     CREATE PROCEDURE procInsertSales   @StoreNumber int,   @Sales int,   @SalesID int OUTPUT AS   INSERT INTO Sales (SalesID, StoreNumber, Sales)   VALUES (@SalesID, @StoreNumber, @Sales) 
  • C.

     CREATE PROCEDURE procInsertSales   @StoreNumber int,   @Sales int,   @SalesID int OUTPUT AS   INSERT INTO Sales (SalesID, StoreNumber, Sales)   VALUES (0, @StoreNumber, @Sales)   SELECT @SalesID = @@IDENTITY 
  • D.

     CREATE PROCEDURE procInsertSales   @StoreNumber int,   @Sales int,   @SalesID int OUTPUT AS   INSERT INTO Sales (StoreNumber, Sales)   VALUES (@StoreNumber, @Sales)   SELECT @SalesID = @@IDENTITY 
Question 46

Your application has two FileStream objects. The fsIn object is open for reading, and the fsOut object is open for writing. Which code snippet would copy the contents of fsIn to fsOut using a 2KB buffer?

  • A.

     Dim buf(2048) As Integer Dim intBytesRead As Integer Do While ((intBytesRead = fsIn.Read(buf, 0, 2048)) >_ 0)     fsOut.Write(buf, 0, intBytesRead) Loop ' Clean up fsOut.Flush() fsOut.Close() fsIn.Close() 
  • B.

     Dim buf(2048) As Integer Dim intBytesRead As Integer Do While ((intBytesRead = fsIn.Read(buf, 0, 2048)) >_ 1)     fsOut.Write(buf, 0, intBytesRead) Loop ' Clean up fsOut.Flush() fsOut.Close() fsIn.Close() 
  • C.

     Dim buf(2048) As Byte Dim intBytesRead As Integer Do While ((intBytesRead = fsIn.Read(buf, 0, 2048)) >_ 0)     fsOut.Write(buf, 0, intBytesRead) Loop ' Clean up fsOut.Flush() fsOut.Close() fsIn.Close() 
  • D.

     Dim buf(2048) As Byte Dim intBytesRead As Integer Do While ((intBytesRead = fsIn.Read(buf, 0, 2048)) >_ 1)     fsOut.Write(buf, 0, intBytesRead) Loop ' Clean up fsOut.Flush() fsOut.Close() fsIn.Close() 
Question 47

You have designed a Windows application that will help users plan, manage, and file their income taxes. Because this market is competitive, you want to list the application in the Microsoft Windows catalog. Which of the following requirements must the application satisfy in order to be listed in the Windows catalog? [Select all that apply.]

  • A. Install to Program Files by default.

  • B. Properly support Add/Remove Programs.

  • C. Support AutoPlay for CDs and DVDs.

  • D. Fix all known bugs in the software.

Question 48

You've written a Windows-based application to search customer information from an XML file. Your application recursively calls the FirstChild and NextChild methods of XmlNode objects to visit every node in an XML file. When you find a node that includes customer name information, you display the information on the form. The application is not returning all the customer names from the file. What could be the problem?

  • A. The XML file is not well formed .

  • B. The XML file has more than one root node.

  • C. The customer name information is stored in XML attributes.

  • D. The HasChildNodes property is not properly set on all nodes.

Question 49

You are developing a Windows-based application for the purchasing department of your company. The department needs to view, add, edit, and update the supplier information stored in a SQL Server database. You must make sure that when the user updates a supplier record, the information is successfully written to the database. Which of the following pairs of method calls should you choose to update the database?

  • A.

     SqlDataTable.AcceptChanges() SqlDataAdapter.Update(DataTable) 
  • B.

     SqlDataAdapter.Update(DataTable) SqlDataTable.AcceptChanges() 
  • C.

     SqlDataTable.Reset() SqlDataAdapter.Update(DataTable) 
  • D.

     SqlDataAdapter.Update(DataTable) SqlDataTable.Reset() 
Question 50

You are developing a Windows-based application that retrieves data from a SQL Server database to perform analysis of sales history. A large number of users will use your application. The size of the sales history data is huge, and your application needs to retrieve this data very quickly. Which of the following techniques would you use to get the maximum performance when retrieving data from the SQL Server database in your Visual Basic .NET application?

  • A. Use the classes from the System.Data.OleDb namespace.

  • B. Use the classes from the System.Data.SqlClient namespace.

  • C. Use the XML Web services to connect with the SQL Server database.

  • D. Use COM components to retrieve the data from the SQL Server database.

Question 51

You're developing a Windows application named OrderManager that allows users to enter new orders and make changes to the existing orders. The application involves a DataTable named OrdersTable, and the column OrderNumber will be the primary key for this table. Which of the following segments of code should you use to define the primary key for OrdersTable in your Visual Basic .NET program?

  • A.

     Dim c As DataColumn() = New DataColumn(1) {} c(0) = t.Columns("OrderNumber") t.PrimaryKey = c 
  • B.

     t.PrimaryKey = "OrderNumber" 
  • C.

     t.PrimaryKey.Add(t.Columns("OrderNumber")) 
  • D.

     t.PrimaryKey = t.Columns("OrderNumber") 
Question 52

You're developing a component using Visual Basic .NET, and other applications will call this component from the Internet. You want to minimize the chance of your component causing unintentional damage to the local computer. As a result, you would like to ensure that your code is not granted file I/O permissions. Which SecurityAction action should you use with the FileIOPermissionAttribute declaration?

  • A. SecurityAction.RequestMinimum

  • B. SecurityAction.RequestOptional

  • C. SecurityAction.Demand

  • D. SecurityAction.RequestRefuse

Question 53

You've designed a Visual Basic .NET application that uses the following code to check for membership in the Developers group:

 Private Sub frmSecure_Load(ByVal sender As System.Object, _  ByVal e As System.EventArgs) Handles MyBase.Load     ' Get the current principal object     Dim prin As WindowsPrincipal = Thread.CurrentPrincipal     ' Determine whether the user is a developer     Dim fDev As Boolean = prin.IsInRole("Developers")     ' Display the results on the UI     If fDev Then         lblMembership.Text = _             "You are in the Developers group"     Else         lblMembership.Text = _             "You are not in the Developers group"     End If End Sub 

Users complain that the code erroneously reports that they are not in the Developers group, even when they are in that group. What must you do to fix this problem?

  • A. Use imperative security to make sure your code has access to the Windows environment variables.

  • B. Create a WindowsIdentity object by using the WindowsIdentity.GetCurrent method and then use this object to construct the WindowsPrincipal object.

  • C. Use the WindowsPrincipal.Name property to retrieve the user's name and then use that name to call the IsInRole method.

  • D. Call AppDomain.CurrentDomain.SetPrincipalPolicy(PrincipalPolicy. WindowsPrincipal) to specify the authentication mode.

Question 54

You are using code access security to verify that your application has permission to perform file I/O operations. As part of your testing procedure, you have created a permission set that denies file I/O permissions. You have also created a code group that uses a hash code membership condition to select your application's executable assembly and assign the permission set to this code group. You have set this code group to be an exclusive code group and have verified that your program is unable to obtain file I/O permissions.

To continue development, you change the code group to use the Everything permission set and continue adding new code to your application. When you're ready to test the security features, you change back to the permission set without file I/O permissions. However, you find that your application is able to access files, even though you have not changed the declarative security within the application.

Why is your code able to perform file I/O even though the code group denies file I/O permissions?

  • A. Changing code within your application changes its hash code, so it is no longer a member of the code group.

  • B. After you've assigned the Everything permission set to a code group, the code group ignores attempts to set more restrictive permissions.

  • C. The Exclusive property on a code group only applies when the code group is first created.

  • D. You must reboot your development computer to update the membership records of the code group.

Question 55

You have converted your application's assembly files to native images using the Native Image Generation tool ( ngen.exe ). Which of the following statements hold true for your assemblies? [Select all that apply.]

  • A. An application that uses a native assembly will run faster for the initial run.

  • B. An application using a native assembly will have consistently faster performance as compared to a JIT-compiled assembly.

  • C. The native assemblies are portable. You should be able to use them on any machine that has the CLR installed on it.

  • D. The native assemblies can be used in debugging scenarios.

Question 56

One of your colleagues is designing a Changed event for his control. He complains to you that his code behaves quite abnormallyit runs fine some of the time but generates exceptions at other times. Part of his event-handling code is listed here (line numbers are for reference purposes only):

 01: Public Delegate Sub ChangedEventHandler _                    (ByVal sender As Object, _                     ByVal args As ColorMixerEventArgs) 02: Public Event Changed As ChangedEventHandler 03: Protected Sub OnChanged(ByVal e As ColorMixerEventArgs) 04:    RaiseEvent Changed() 05: End Sub 

Which of the following changes to the code in line 4 will solve his problem?

  • A.

     RaiseEvent Changed(Me) 
  • B.

     RaiseEvent ChangedEventHandler(Me) 
  • C.

     RaiseEvent ChangedEventHandler(Me, e) 
  • D.

     RaiseEvent Changed(Me, e) 
Question 57

You are a programmer for a popular gaming software publishing company. The company has recently designed a series of games using the .NET Framework. All these new game applications share some components. Some of these components are shipped in the box with the applications, and others are deployed over the Internet. Which of the following commands will you use for these components before packaging them for deployment?

  • A. Use sn.exe to sign the components.

  • B. Use signcode.exe to sign the components.

  • C. Use sn.exe followed by signcode.exe to sign your components.

  • D. Use signcode.exe followed by sn.exe to sign your components.

Question 58

When you install a Windows application on a target machine, you want to store the Readme.txt file in the directory selected by the user to install the application. You also want to create a shortcut for the Readme.txt file on the desktop of the target machine. While creating a Setup project, which of the following actions will you take in the File System Editor to achieve this? [Select all that apply.]

  • A. Move the shortcut to the Readme.txt file from the Application Folder to the user's desktop in the file system on the target machine.

  • B. Add the Readme.txt file to the Application Folder node of the file system on the target machine.

  • C. Create a shortcut to the Readme.txt file in the Application Folder node of the file system on the target machine.

  • D. Add the Readme.txt file to the user's desktop in the file system on the target machine.

  • E. Move the shortcut to the Readme.txt file from the user's desktop to the Application Folder in the file system on the target machine.

Question 59

You have developed a Windows application that assists users in maintaining their timesheets. After successfully testing the application, you decide to deploy it on users' computers. You ask four users to install the application on their computers and provide feedback. Three users reported that they are able to create timesheets and are happy with the application's performance. However, the fourth user reports that she is getting an error message similar to "The dynamic link library mscoree.dll could not be found." Which of the following steps should you suggest the user take in order to resolve this error message?

  • A. Ask the user to copy all assemblies from the \bin folder to the Global Assembly Cache.

  • B. Ask the user to install the application after installing Internet Explorer 6.0.

  • C. Ask the user to install the application after installing MDAC 2.7.

  • D. Ask the user to install the application after installing the .NET Framework.

Question 60

You use Visual Basic .NET to develop a component named ReplicateWarehouseData. This component replicates the data used by the Warehousing application developed by the Warehouse Development team of your company. The Warehouse Development team needs to deploy the Warehousing application to its first three customers. How should the team deploy this application?

  • A. Create a Merge module for the ReplicateWarehouseData component.

  • B. Create a Setup project to deploy the application and include the Merge module containing the component in the Setup project.

  • C. Copy the ReplicateWarehouseData component into the directory of the Warehousing application.

  • D. Create a Setup project to deploy the application that contains the code for the component.



Developing and Implementing WindowsR-based Applications with Visual BasicR. NET and Visual StudioR. NET Exam CramT 2 (Exam 70-306)
Developing and Implementing WindowsR-based Applications with Visual BasicR. NET and Visual StudioR. NET Exam CramT 2 (Exam 70-306)
ISBN: N/A
EAN: N/A
Year: 2002
Pages: 188

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net