Answers to Exam Questions

A1: C. You should use Process.CloseMainWindow() to shut down any application that has a user interface. This method gives the application a chance to clean up resources. Process.Kill() also shuts down the application, but it does not let normal cleanup processing proceed.
A2: C. Dynamic properties provide a built-in mechanism to set properties at runtime without requiring you to write any code.
A3: D. You need to sign the code with sn.exe to give it a strong name so that it can be stored in the GAC, and you need to sign it with signcode.exe to give it an Authenticode signature. The two tools should always be used in that order.
A4: D. A conditional breakpoint lets you pause code only when a particular condition is true. In this case, you can use that capability to break into the code when the variable has the value 17.
A5: A. Setting the PrintPreviewControl.UseAntiAlias property to true gives you a higher-quality print preview. The tradeoff is longer rendering times.
A6: D. Because the application uses a Web service, you're assured that users have Internet access. Placing the help file on an Internet server allows you to display it on the form like any other help file but to change it quickly in one central location when it needs to be updated.
A7: C. In the PInvoke calls, you should use StringBuilder instead of String to hold the return value.
A8: C. RCWs let you call existing COM components from .NET code without requiring a code rewrite.
A9: D. Setting the CausesValidation property of a control to false causes the Validating events of other controls to be ignored when the focus is shifted to the specified control.
A10: D. The Invalidate() method triggers the Paint event, so calling it within the Paint event leads to an infinite regress. You could call the Invalidate() method periodically or in response to a Resize event, but using the ResizeRedraw property requires less code and is thus the preferable solution.
A11: C. Setting the control's TabStop property to false removes the control from the tab order. If you set the control's Enabled property to false, the control cannot get the focus under any circumstances.
A12: B and D. The .NET WebService Studio tool is used to invoke a Web service for testing. The Web Services Discovery tool can locate files that are related to a Web service, but it does not build any code. The other two methods can generate proxy classes for use in a client application.
A13: A. For information that will not be directly displayed to an end user but that may need to be used from many different locales, the invariant culture provides a culture-neutral storage format.
A14: C. Using the Or (|) operator sets the proper bit to represent the Italic FontStyle without altering any other bits that may already be set.
A15: A. If resources from a specific culture are not found, the .NET Framework falls back to using resources from the appropriate neutral culture, in this case the fr culture.
A16: D. To display values from an array in a ListBox control or a ComboBox control, you set the DisplayMember property of the control to a string that contains the name of the field.
A17: C. The filters in the OpenFileDialog control are numbered, starting at 1. The first filter, Image Files (BMP, GIF, JPEG, etc.)| "*.bmp;*.gif;*.jpg;*.jpeg;*.png;*.tif;*.tiff, having FilterIndex set to 1, displays all the files; the second filter, BMP Files (*.bmp)|*.bmp, having FilterIndex set to 2, displays only the .bmp files.
A18: D. Because the COM library comes from a third-party company, the only proper way to proceed is to obtain a PIA from that company. You should not import and sign code that you did not write yourself.
A19: A. You need to set PrintPageEventArgs.HasMorePages to true in the PrintPage event when more than one page needs to be printed in the current print job.
A20: D. The public, remotely accessible methods of a Web service are methods that are marked with the WebMethod attribute.
A21: A. Only assemblies with strong names can be installed in the GAC. This allows the CLR to ensure that an assembly has not been tampered with and prevents naming collisions with assemblies from other developers.
A22: A. You must set the EventLog.EnableRaisingEvents property to true to handle events from an event log in your code.
A23: C. The COM component is used in only one project, so there's no penalty for using the easy direct reference method to use the objects in the COM component.
A24: B. The PrintDialog component displays the standard Windows Print dialog box.
A25: A. Array.Sort does not locate substrings. String.IndexOf and String.IndexOfAny can find substrings, but they are not culture-aware. Only the CompareInfo object can correctly handle the search in all character sets, including those that use 2 bytes per character.
A26: B. Both the original object on the server and the proxy object on the client are instances of the same class, so both projects need a reference to the namespace that defines the class.
A27: D. The DataView object provides a customized, bindable view of a DataTable object.
A28: B. Because the Graphics object is so frequently needed during the Paint event, it is automatically passed to that event's handler.
A29: D. Calls to a Web service will block other processing unless you use asynchronous calls to invoke the Web service.
A30: C. To fill a DataSet object, you pass both the DataSet object and the name of the DataTable object to be created to the Fill() method of an appropriate DataAdapter object.
A31: A. The protected modifier limits member access to the class that contains the member and to subclasses of that class. public allows any class to call the member. private limits access to the defining class only. internal limits access to classes within the same project, whether they are derived from the defining class or not.
A32: A. The MaxLength property only has an effect on user input. It is not checked when you programmatically set the value of a control.
A33: A. Assigning a value directly to the BackColor property of Form2 overrides the inheritance from Form1. Further changes to the same property on Form1 do not have any effect on Form2.
A34: A. Assemblies installed in the GAC are available to all .NET code on the computer.
A35: B. The UserControl class provides you with a design surface on which you can assemble constituent controls to create a custom control.
A36: A. Using simple data binding is the easiest way to move values from one database table to another via controls on a Windows form.
A37: D. A parameterized stored procedure allows you to pass in a parameter (in this case, the identifier for the customer) and use the parameter to limit the data returned.
A38: B. You should avoid duplicating code if you don't have to. However, the Click and MouseMove event handlers of the Button control have different signatures. So you need to write two event handlers: one to handle both Click events and one to handle both MouseMove events.
A39: D. The GetBytes() method of any encoding translates from Unicode characters to bytes that are appropriate for the Encoding object that's in use.
A40: C. The TRACE symbol is defined in both the default Debug configuration and the default Release configuration. The DEBUG symbol is defined only in the default Debug configuration.
A41: A. By default, Windows displays all Trace messages in the output window. If you add another TraceListener object to the Listeners collection of the Trace object, messages are sent to the new listener and to the output window.
A42: A. The UserPreferenceChanged event is raised whenever the user changes display properties. You can check the SystemInformation.HighContrast property in this event to determine whether the user has entered high-contrast mode.
A43: B. The Font.GetHeight() method allows you to determine the vertical size of the font so you can adjust the printing position of lines on the page.
A44: C. The Help.ShowHelp() method displays the contents of a specified help file, without requiring a keyword or topic name.
A45: A. Allowing the user to choose a culture is better than accepting the existing culture of the application because the user might be running a version of Windows that's not appropriate for his or her culture. There's no need to prompt for or store a numeric format because all necessary formats are stored in the .NET Framework.
A46: A. You can have only a single SqlDataReader object open on a single SqlConnection object. If you need a second SqlDataReader object, you need to open a second SqlConnection object.
A47: A. The Web Services Discovery tool uses the information in the .asmx file to locate the other important files for the Web service, including the WSDL file that specifies the Web service's interface.
A48: D. Changes that are made to a DataGrid control that is bound to a DataSet control are automatically saved to the DataSet control. However, they are not persisted to the underlying data source until you call the Update() method of the DataAdapter object that was used to fill the DataSet control.
A49: C. The BinaryReader class uses an efficient encoding method to write data to disk, but the results are not human readable.
A50: C. The FileStream class is designed for byte-by-byte input and output. The other classes add additional functionality, but they require you to have prior knowledge of the structure of the file you're reading.
A51: D. Using a class derived from EventArgs to pass event parameters is preferable to using individual arguments because it can more readily be extended in case you need to pass additional parameters in the future.
A52: B. Using the Type Library Importer allows you to place the RCW assembly in the GAC so that it can be shared by all projects on the computer. A PIA is for code from other vendors, not for your own code.
A53: A. An application that must deploy assemblies to the GAC should be deployed by using Windows Installer.
A54: A. The installutil.exe tool treats each command line as a single transaction. If any of the assemblies listed in the command fails to install, the entire installation is rolled back.
A55: A. System.Data.SqlClient.SqlConnection offers the best possible performance for SQL Server data sources because it talks directly to SQL Server by using the native TDS protocol.
A56: B. A cryptographic hash uniquely identifies a particular version of a particular assembly. You can't use a software publisher membership condition because the code does not have an Authenticode signature.
A57: D. The QueryPageSettings event fires before each page is printed and allows you to check and change page settings. Page settings cannot be changed in the PrintPage event.
A58: C. The KeyDown event occurs before the KeyPress events. Setting the Handled property to true in the form's KeyPress event prevents the control's KeyPress event from firing.
A59: C. The help button will be displayed on the title bar only if both the MinimizeBox and MaximizeBox properties are set to false.
A60: D. You can enumerate and retrieve entries from the remote event logs, but you can only post new entries to an event log on the local computer.
A61: B and D. The AccessibleName and AccessbleDescription properties provide information directly to screen reader programs.
A62: A, C, and D. These are the three constructors that any Exception class should implement. Custom exception classes require the same three constructors that are defined in the base System.Exception class.
A63: C. With code access security, you can use OleDbPermission to grant permission to use OLE DB data sources.
A64: D. Strings in Visual C# .NET are immutable, so concatenating multiple values into a string requires you to delete and re-create the string many times. The StringBuilder object is optimized for changing textual data.
A65: B. Breakpoints and other debugging features are not enabled in the default Release configuration.
A66: A. Within a level, the permission set granted to an assembly is the union of all the permission sets of code groups on that level to which the assembly belongs.
A67: A. To pause the rest of the application while the user makes a choice, you should use the ShowDialog() method rather than the Show() method to display the form. When the user clicks a button on the form, the value of the DialogResult property of that button is assigned to the DialogResult property of the form.
A68: A. To enable remote debugging on a computer, the Machine Debug Manager must be installed. You can install this software by installing Visual Studio .NET on the remote machine or by installing Remote Components Setup on the remote machine.
A69: D. When a custom control does not require a runtime user interface, the Component class provides the lowest overhead.
A70: A. If a CheckBox control has its ThreeState property set to true, its Checked property returns true even if the check box is in the indeterminate state. You must evaluate the CheckState property to determine whether the check box is actually checked.
A71: B. The easiest way to get a control to behave precisely like a TextBox control is to inherit from the TextBox class.
A72: B. A Windows Installer merge module allows you to include the component in any installer package, and the merge module will have identical settings in every package. You cannot use XCOPY deployment to meet these requirements because the component requires Registry settings.
A73: B. With a SecurityAction.RequestOptional request, you can trap the error if the permission is not granted.
A74: D. An exception is handled by the most specific applicable catch block. A transfer-of-control statement (such as goto) does not skip a finally block.
A75: D. The INSERT statement adds a new row to a SQL Server (or other ANSI SQL-compliant database) table.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.223.196.171