Practice Questions

Question 1

You need to create several forms capable of accepting and validating addresses as well as accepting information such as name, street name , state, country, and Zip code using TextBox and ComboBox controls. You want to package your input and validation code in a standard component so that you can re-use the control. Which of the following classes should be the base class of your component?

  • A. System.Windows.Forms.Control

  • B. System.Windows.Forms.UserControl

  • C. System.Windows.Forms.Form

  • d. System.ComponentModel.Component

A1:

Answer B is correct. The System.Windows.Forms.UserControl class provides the capability to quickly create a reusable component by combining existing Windows controls. Answer A is incorrect because extending the base Control class provides a means to create your own controls from scratch rather than simply reusing existing Windows controls. Answer C is incorrect because you would not use a form within another form as a control. Answer D is incorrect because the base Component class is extended to create nonvisual components .

Question 2

You have defined a custom user -authentication component that raises an Authenticated event whenever a user is successfully authenticated. When this event fires, you want to make the username and SID (security identifier) available to the control container. How should you accomplish this requirement?

  • A. Place the username and SID in properties of the component for the container to retrieve.

  • B. Pass the username and SID as parameters of the Authenticated event.

  • C. Define global variables in a separate module and place the values in those variables .

  • D. Define a custom AuthenticatedEventArgs class that inherits from the EventArgs class and pass it as a parameter of the Authenticated event.

A2:

Answer D is correct. Using a class derived from EventArgs to pass event parameters is preferable to using individual arguments because it is easier to extend to include more parameters later. Answers A, B, and C are incorrect because they all involve placing the variables in other locations, making them harder to manipulate and update. Answer C also involves the use of a separate module, where the code from your control might be unable to effect changes.

Question 3

A friend attempts to host a control in Internet Explorer. He creates the control and tests it successfully on a Windows form, but he can't get it to display in IE. The name of the control is SolidControls.ColorMixer, within a DLL named SolidControlsLib.dll . He has placed both the HTML page and the DLL in the same virtual directory on the Web server.

He shows you the HTML file that hosts this control. Part of his HTML code is listed below (line numbers are for reference purpose only):

 01: <html> 02:    <body> 03:        <object id="colorMixerX1" 04:            classid="http://localhost/WebDir/SolidControlsLib.dll" 05:            height="300" width="300"> 06:        </object> 07:    </body> 08: </html> 

What change is needed to display this control in IE?

  • A. Change the code in line 4 to

     classid="http://localhost/WebDir/SolidControlsLib.dll#SolidControls.ColorMixer" 
  • B. Change the code in line 4 to

     classid="http://localhost/WebDir/SolidControlsLib.dll?SolidControls.ColorMixer" 
  • C. Change the code in line 4 to

     classid="SolidControls.ColorMixer" 
  • D. Change the code in line 4 to

     classid="http://localhost/WebDir/SolidControlsLib.dll?classid=SolidControls.ColorMixer" 
A3:

Answer A is correct. The correct usage is to give the classid a string having the virtual path to the control and the namespace-qualified name of the control class, separated by the pound sign ( # ). Answer B is incorrect because the separating character is specified as the question mark ( ? ) symbol. Answer C is incorrect because it is missing the virtual path assignment. Answer D is incorrect because it includes a second classid assignment as a divider.

Question 4

You have installed BigLibrary.dll version 1.0.0.0 in the Global Assembly Cache on your computer. Existing applications use this version. Now you are installing an application that uses BigLibrary.dll version 2.0.0.0. You want this new version to be available to any application that uses it. How should you install the new version?

  • A. Leave version 1.0.0.0 in the GAC and install version 2.0.0.0 in the application directory of each application that requires it.

  • B. Replace version 1.0.0.0 in the GAC with version 2.0.0.0.

  • C. Add version 2.0.0.0 to the GAC along side version 1.0.0.0.

  • D. Delete version 1.0.0.0 from the GAC. Copy version 1.0.0.0 to the application directory of each application that requires it. Install version 2.0.0.0 to the GAC.

A4:

Answer C is correct. Assemblies located within the Global Assembly Cache may have files with the same name, differentiated by version number. Each application will then link to the version it requests . Answer A is incorrect because it does not automatically make version 2.0.0.0 available to new applications. Answer B is incorrect because it will break existing applications that use version 1.0.0.0. Answer D is incorrect because it doesn't allow for new applications to use version 1.0.0.0.

Question 5

You are creating an application that will be used companywide . Several forms show a clock to the user. You decide to code the custom analog clock as a reusable component. Which of the following classes should be the base class for creating this control?

  • A. System.Windows.Forms.Control

  • B. System.Windows.Forms.UserControl

  • C. System.Windows.Forms.Form

  • D. System.ComponentModel.Component

A5:

Answer A is correct. You should inherit from the Control class if you want to provide a custom graphical representation of your control or functionality that is not available through standard controls. Answer B is incorrect because the UserControl class provides the capability to quickly create a reusable component by combining existing Windows controls. Answer C is incorrect because you would not use a form within another form as a control. Answer D is incorrect because the base Component class is extended to create nonvisual components.

Question 6

You have designed a custom user control combining five TextBox controls and two Button controls. You do not want the client application to be able to access the contained objects within your control. Which modifiers should you use to achieve this requirement? [Select all correct answers.]

  • A. Private

  • B. Friend

  • C. Protected

  • D. Public

A6:

Answers A and B are correct. When you configure the contained objects within a control as Friend or Private, they are not accessible to the client application for direct manipulation. Answer C is incorrect because the Protected setting only limits access to the same project, and Answer D is incorrect because Public assignment allows access from any solution.

Question 7

You are designing a component that interacts with the computers in a network. The component has no visual representation but should provide you a design time interface that will help client application designers to set its properties and behavior. Which of the following should you chose as the base class for this control?

  • A. System.Windows.Forms.Control

  • B. System.Windows.Forms.UserControl

  • C. System.Windows.Forms.Form

  • D. System.ComponentModel.Component

A7:

Answer D is correct. Components that provide no visual interface should derive directly from the System.ComponentModel.Component class. Answers A and B are incorrect because the Control and UserControl classes are used for components needing a visual representation. Answer C is incorrect because a Form class is used as a container for other controls and includes a visual representation.

Question 8

Your Windows application utilizes several graphics files. You don't want to have to distribute additional files with your application. What should you do?

  • A. Create a satellite assembly for storing graphics

  • B. Set the BuildAction property of the graphics files to Content

  • C. Set the BuildAction property of the graphics files to Compile.

  • D. Set the BuildAction property of the graphics files to Embedded Resources

A8:

Answer D is correct. When you set the BuildAction property of a graphic file to Embedded Resources, the file is embedded with the main assembly file (DLL or EXE). Answer A is incorrect because a satellite assembly is used to include culture-specific information. Answer B is incorrect because the Content setting causes the compilation to result in a main file that includes only code, metadata, and references to external resource files that must be distributed with the main file. Answer C is incorrect because compilation is the process by which the assembly EXE or DLL is created.

Question 9

Your application uses a library written in VB .NET. The library assembly is installed to the Global Assembly Cache. You are finding that your application's startup performance is poor. What can you do to make this library load more quickly?

  • A. Precompile the library to a native image.

  • B. Delete the library from the GAC and install it in the application directory.

  • C. Rewrite the library in C#.

  • D. Assign the library a strong name.

A9:

Answer A is correct. Native images of assemblies are precompiled and are as fast the first time as in succeeding uses. If an assembly isn't saved as a native image, it must be JIT-compiled at first use, which takes additional time. Answers B and C are incorrect because the location and the language of the library don't affect its loading time. Answer D is incorrect because the library must already have a strong name if it is installed to the GAC.

Question 10

Which of the following statements is true for a multifile assembly?

  • A. Each file must contain an assembly manifest.

  • B. Only one of the files can contain the assembly manifest.

  • C. You can find the assembly to which a file belongs by opening that file with the MSIL Disassembler ( ildasm.exe ).

  • D. You can have files with the same name but different versions in a multifile assembly without conflicts.

A10:

Answer B is correct. Only one of the files in a multifile assembly can contain the assembly manifest. Answer A is incorrect because only one assembly manifest exists for each assembly. Answer C is incorrect because you cannot find the name of an assembly to which a file belongs by viewing it in ILDASM. Only the assembly manifest contains this information. Answer D is incorrect because it is not possible to have two files with same name in an assembly. Also, the most elementary unit of versioning is the assembly itself, so the files contained in it cannot have different versions.



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