Exam Prep Questions

Question 1

You are building a new control that will track Quality of Service (QoS) by issuing pings from the browser and uploading the results. The control will not have a runtime user interface. What type of control should you create?

  • A. Composite Web custom control

  • B. Web custom control that inherits directly from Label

  • C. Web custom control that inherits directly from WebControl

  • D. Web user control

A1:

Answer C is correct. The control in question doesn't require a user interface, so you can build it simply by deriving it directly from the WebControl class. Answers A, B, and D are incorrect because a composite Web custom control, a control derived from the Label control, and a Web user control are useful only when providing a runtime user interface.

Question 2

You are developing a component that needs to expose a property named Count to its container. The Count property should be read-only. How should you implement the property?

  • A.

     private int count; public int Count {     get {return count;} } 
  • B.

     private int count; public int Count {     get {count = value;} } 
  • C.

     private int Count; 
  • D.

     private int count; public int Count {     get {return count;}     set {count = value;} } 
A2:

Answer A is correct. To create a read-only property, you simply need to define a get accessor for the property. Answer B is incorrect because the get accessor is not returning any value. Answer C is incorrect because it declares a private variable called Count , which will not be accessible from the container control. Answer D is incorrect because the set accessor allows you to perform a write operation on the property.

Question 3

You have created a custom component that reads configuration information from a database. Because many instances of this component might be in operation at any given time, you decide to implement a Dispose() method in the component to close the database connection. The database connection is represented by a class-level member variable called mcnn . How should you implement the Dispose() method?

  • A.

     protected override void Dispose                   (bool disposing) {     if (!disposing)         if(components == null)             components.Dispose();     base.Dispose(disposing);     mcnn.Close();     mcnn = null; } 
  • B.

     protected override void Dispose                    (bool disposing) {     if (disposing)         if(components != null)             components.Dispose();     base.Dispose(disposing);     mcnn.Close();     mcnn = null; } 
  • C.

     protected override void Dispose                    (bool disposing) {     if (!disposing)        base.Dispose(disposing);        mcnn.Close();        mcnn = null; } 
  • D.

     protected override void Dispose                    (bool disposing) {     if (disposing)     {         components.Dispose();     }     base.Dispose(disposing);     mcnn.Close();     mcnn = null; } 
A3:

Answer B is correct. The Dispose() method should call Dispose() on its own Components collection, but only if the disposing parameter is set to true (because you want to dispose of managed resources) and if the collection actually exists. Answers A and C are incorrect because the disposing parameter is set to false for releasing unmanaged resources only. Answer D is incorrect because it does not check whether the Components collection already exists before calling the Dispose() method.

Question 4

You have created a Web user control named menu.ascx that encapsulates the standard navigation menu to be used on your company's Web sites. You now want to use this control in Web applications other than the one in which you built the control. What should you do?

  • A. Install the control in the GAC.

  • B. Include the control's project in the solution containing each application.

  • C. Copy the control's files into each application.

  • D. Compile the control and copy the compiled assembly into each application's bin folder.

A4:

Answer C is correct. A Web user control can be used only by a project containing the control's files. Answer A is incorrect because only assemblies and not source files (such as menu.ascx ) can be installed in the GAC. Answer B is incorrect because there is no need to include the whole project when all you need is the .ascx file. Answer D is incorrect because, although you can compile the code-behind file, the .ascx file must still be copied to every application.

Question 5

You have created a Web custom control named menu.cs that encapsulates the standard navigation menu to be used on your company's Web sites. You now want to use this control in Web applications other than the one in which you built the control. What should you do?

  • A. Install the control in the GAC.

  • B. Include the control's project in the solution containing each application.

  • C. Copy the control's files into each application.

  • D. Compile the control and copy the compiled assembly into each application's bin folder.

A5:

Answer A is correct. A Web custom control can be used by any application that can set a reference to the compiled version of the control. If you install a Web custom control in the GAC, it can be used by any application on the computer. Answers B, C, and D are incorrect because when an assembly is used by multiple applications, the best choice is to install the assembly to the GAC.

Question 6

You are creating a Web custom control by inheriting directly from the System.Web. UI .WebControls.WebControl class. What can you do to provide a design-time representation of your control? (Select two.)

  • A. Implement an Init() method that returns HTML text.

  • B. Implement a Render() method that returns HTML text.

  • C. Create a control designer class and specify it using attributes of the control class.

  • D. Include a bitmap of the control in the assembly with the control's code.

A6:

Answers B and C are correct. The design-time representation of a control is composed of HTML code representing the control. This HTML code can come from the control's Render() method or from the GetDesignTimeHtml() method of a control designer class. Answer A is incorrect because you should only write the code to initialize a server control inside the Init() method. All rendering code must be part of the Render() method. Answer D is incorrect because including a bitmap of the control in the assembly is just a mechanism for packaging the resources and will not help you provide a design-time interface for the control.

Question 7

You are creating an ASP.NET Web application to serve as the Web site for a small business client. Each page in the site will have the same controls functioning as a menu. You won't need to reuse these controls for any other project. What type of control should you create to represent the menu?

  • A. Composite Web custom control

  • B. Web custom control that inherits directly from Label

  • C. Web custom control that inherits directly from WebControl

  • D. Web user control

A7:

Answer D is correct. For reuse in a single project, a Web user control is the quickest and easiest choice. Answers A, B, and C are incorrect because custom controls require additional programming efforts and are mostly suitable when they are reused across multiple projects.

Question 8

You are creating a specialized control that will manage image uploads for your company. This control must be installed into the Visual Studio toolbox so that it can be used in many projects. The control's user interface will be a single button that can be used to browse for a file. Which type of control should you create?

  • A. Composite Web custom control

  • B. Web custom control that inherits directly from Button

  • C. Web custom control that inherits directly from WebControl

  • D. Web user control

A8:

Answer B is correct. For toolbox support, you need to use a Web custom control. Answers A, C, and D are incorrect because, when the user interface is similar to an existing control, you should derive your new control directly from that control.

Question 9

You have a standard set of controls you use to implement menus in Web applications for a wide variety of customers. These controls include a series of LinkButtons, Images , and Labels . You've decided that you want to encapsulate these controls for easy reuse. Which type of control should you create?

  • A. Composite Web custom control

  • B. Web custom control that inherits directly from Label

  • C. Web custom control that inherits directly from WebControl

  • D. Web user control

A9:

Answer A is correct. You can encapsulate multiple controls in either a Web user control or a composite Web custom control. The composite control is a much better choice for use in multiple projects because it can be added to the GAC and the toolbox. Answers B and C are incorrect because, when you inherit directly from the Label or WebControl class, you inherit the functionality of just one control. Answer D is incorrect because a Web user control cannot be added to the GAC and toolbox.

Question 10

You have created a Web custom control you will be using in numerous ASP.NET applications on multiple servers. You are considering installing the control in the GAC. What is a potential drawback of this action?

  • A. Controls in the GAC cannot be used by ASP.NET applications.

  • B. Controls in the GAC cannot be signed to ensure their security.

  • C. You cannot deploy a control to the GAC via FTP or XCOPY.

  • D. The GAC can contain only one version of any particular control.

A10:

Answer C is correct. To deploy a control to the GAC, you must use a setup program, which can be a problem if you're managing multiple remote Web servers. Answer A is incorrect because ASP.NET applications can use controls from the GAC without problems. Answer B is incorrect because the controls in the GAC must be signed. Answer D is incorrect because the GAC can host more than one version of the same control without conflicts.



MCAD Developing and Implementing Web Applications with Visual C#. NET and Visual Studio. NET (Exam [... ]am 2)
MCAD Developing and Implementing Web Applications with Visual C#. NET and Visual Studio. NET (Exam [... ]am 2)
ISBN: 789729016
EAN: N/A
Year: 2005
Pages: 191

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