Testking Cisco 642-845 test training

Chapter 1: Lesson Review Answers
Lesson 1

1.Which of the following code snippets demonstrates how to add a new instance
of a Windows Form named Form1 at run time? 642-425
A. ‘ VB
Dim myForm As Form1
myForm = Form1.CreateForm()
// C#
Form1 myForm;
myForm = Form1.CreateForm();
B. ‘ VB
Dim myForm As Form1
myForm.Show()
// C#
Form1 myForm;
myForm.Show();
C. ‘ VB
myForm = Form1
myForm.Show()
// C#
myForm = Form1;
myForm.Show();
D. ‘ VB
Dim myForm As Form1
myForm = New Form1()
// C#
Form1 myForm;
myForm = new Form1();
1. Correct Answer: D 642-426
A. Incorrect. There is no CreateForm method on a Form class. A new form is
created by using the New keyword.
B. Incorrect. You must create a new instance of Form1 with the New keyword
before calling methods on that instance.
C. Incorrect. myForm is not declared, and you cannot assign an instance vari-
able to a class, although in Microsoft Visual Basic, “Form1” would return
the default instance of Form1.
D. Correct. myForm is correctly declared and instantiated.

2.Which of the following code snippets correctly demonstrates how to set a form
to a non-rectangular shape? 642-432
A. ‘ VB
Dim aPath As New System.Drawing.Drawing2D.GraphicsPath
aPath.AddEllipse(0, 0, Me.Width, Me.Height)
Me.Region = New Region();
// C#
System.Drawing.Drawing2D.GraphicsPath aPath = new
System.Drawing.Drawing2D.GraphicsPath();
aPath.AddEllipse(0, 0, Me.Width, Me.Height);
this.Region = new Region();
B. ‘ VB
Dim aPath As New System.Drawing.Drawing2D.GraphicsPath
aPath.AddEllipse(0, 0, Me.Width, Me.Height)
// C#
System.Drawing.Drawing2D.GraphicsPath aPath = new
System.Drawing.Drawing2D.GraphicsPath();
aPath.AddEllipse (0, 0, Me.Width, Me.Height);
C. ‘ VB 642-445
Dim aPath As New System.Drawing.Drawing2D.GraphicsPath
aPath.AddEllipse(0, 0, Me.Width, Me.Height)
Me.Region = New Region(aPath)
// C#
System.Drawing.Drawing2D.GraphicsPath aPath = new
System.Drawing.Drawing2D.GraphicsPath();
aPath.AddEllipse(0, 0, Me.Width, Me.Height);
this.Region = new Region(aPath);
D. ‘ VB
Dim aPath As New System.Drawing.Drawing2D.GraphicsPath
aPath.AddEllipse(0, 0, Me.Width, Me.Height)
Me.Region = aPath
// C#
System.Drawing.Drawing2D.GraphicsPath aPath = new
System.Drawing.Drawing2D.GraphicsPath();
aPath.AddEllipse(0, 0, Me.Width, Me.Height)
this.Region = aPath;
2. Correct Answer: C
A. Incorrect. You must supply the new path as a parameter in the Region con-
structor.
B. Incorrect. You must set the Region to the new instance of the path.
C. Correct. This code snippet creates an elliptical GraphicsPath and then cre-
ates a new region from that GraphicsPath and assigns it to the Region prop-
erty of the Form.
D. Incorrect. You cannot set the Region property to a GraphicsPath. You must
first create a new Region from the GraphicsPath. 642-456

3. Which of the following code samples correctly sets the title, border style, size,
and opacity of a form?
A. ‘ VB
Me.Text = “My Form”
Me.FormBorderStyle = FormBorderStyle.Fixed3D
Me.Size = New Size(300, 300)
Me.Opacity = 0.5
// C#
this.Text = “My Form”;
this.FormBorderStyle = FormBorderStyle.Fixed3D;
this.Size = new Size(300, 300);
this.Opacity = 0.5;
B. ‘ VB
Me.Text = “My Form”
Me.BorderStyle = “Fixed3D’
Me.Size = New Size(300, 300)
Me.Opacity = 0.5 642-513
// C#
this.Text = “My Form”;
this.BorderStyle = “Fixed3D”;
this.Size = new Size(300, 300);
this.Opacity = 0.5;
C. ‘ VB
Me.Text = “My Form”
Me.FormBorderStyle = FormBorderStyle.Fixed3D
Me.Size = (300,300)
Me.Opacity = “100%”
// C#
this.Text = “My Form”;
this.FormBorderStyle = FormBorderStyle.Fixed3D;
this.Size = (300,300);
this.Opacity = “100%”;
D. ‘ VB
Me.Title = “My Form”
Me.FormBorderStyle = FormBorderStyle.Fixed3D
Me.Size = New Size(300,300)
Me.Opacity = “100%” 642-523
// C#
this.Title = “My Form”;
this.FormBorderStyle = FormBorderStyle.Fixed3D;
this.Size = new Size(300,300);
this.Opacity = “100%”;
3. Correct Answer: A
A. Correct. All properties are set to appropriate values.
B. Incorrect. The FormBorderStyle property should be set to a member of the
FormBorderStyle enumeration, not to a string.
C. Incorrect. The Opacity property should be set to a value between 0 and 1,
not to a string value, and the form’s Size property should be set to a new
instance of the Size structure.
D. Incorrect. The Opacity property should be set to a value between 0 and 1,
not to a string value.

Lesson 2
1.Which of the following code samples correctly demonstrates how to set a flow
break on a control named aButton in a FlowLayoutPanel named FLPanel1?
A. ‘ VB
aButton.SetFlowBreak()
// C# 642-533
aButton.SetFlowBreak();
B. ‘ VB
aButton.SetFlowBreak(FLPanel1)
// C#
aButton.SetFlowBreak(FLPanel1);
C. ‘ VB
FLPanel1.SetFlowBreak(aButton)
// C#
FLPanel1.SetFlowBreak(aButton);
D. ‘ VB
FLPanel1.aButton.SetFlowBreak
// C#
FLPanel1.aButton.SetFlowBreak();
1. Correct Answer: C
A. Incorrect. The Button class does not expose a SetFlowBreak method.
B. Incorrect. Flow breaks are set by the FlowLayoutPanel, not by the hosted
control.
C. Correct. Use the SetFlowBreak method to set a flow break.
D. Incorrect. You cannot access contained controls as members of a container
control. 642-587

2.You are designing an application that includes a property page that enables the
user to set properties of the application. These properties are divided into three
categories: Appearance, Execution, and Memory Management. Which container
control represents the best starting point for the user interface?
A. TableLayoutPanel
B. FlowLayoutPanel
C. GroupBox
D. TabControl
2. Correct Answer: D
A. Incorrect. The TableLayoutPanel is best for organizing controls in a tabular
style. Although it might be a good choice for a single set of properties, it is
not a good choice for separating groups.
B. Incorrect. The FlowLayoutPanel is best for organizing controls that re-ori-
ent themselves in response to resizing of the control, but it is not a good
choice for presenting multiple groups of controls. 642-611
C. Incorrect. The GroupBox is best used for presenting radio buttons that pro-
vide the user with exclusive choices between two or more options.
D. Correct. The TabControl is best used for organizing related controls into
individual related groups.

3. Which of the following is the correct way to add a control to a form at design
time? (Choose all that apply.)
A. Select a control in the Toolbox and double-click the form.
B. Select a control in the Toolbox and draw the form with the mouse.
C. Double-click the control in the Toolbox.
D. Select the control in the Toolbox and drag it to the form.
3. Correct Answers: A, B, C, and D
A. Correct. Each of these methods is valid.
B. Correct. Each of these methods is valid.
C. Correct. Each of these methods is valid.
D. Correct. Each of these methods is valid.

4.Which of the following code samples demonstrates the correct way to add a But-
ton control to a form named Form1 at run time? 642-642
A. ‘ VB
Form1.Controls.Add(Button)
// C#
Form1.Controls.Add(Button);
B. ‘ VB
Dim aButton As New Button
Form1.Controls.Add(aButton)
// C#
Button aButton = new Button();
Form1.Controls.Add(aButton);
C. ‘ VB
Dim aButton As New Button
Form1.Add(aButton)
// C#
Button aButton = new Button();
Form1.Add(aButton);
D. ‘ VB
Form1.Add(New Button) 642-811
4. Correct Answer: B
A. Incorrect. You cannot add a type to the controls collection. You must create
an instance of the control first.
B. Correct. You must first instantiate the control and then add it to the form’s
controls collection.
C. Incorrect. The Add method is a member of the Form.Controls collection,
not a member of Form itself.
D. Incorrect. The Add method is a member of the Form.Controls collection,
not a member of Form itself.

5.Which code sample correctly demonstrates how to add a new panel to a Split-
Container named SpC1? 642-812
A. ‘ VB
SpC1.Controls.Add(New Panel)
// C#
SpC1.Controls.Add(new Panel());
B. ‘ VB
SpC1.Controls.Add(New SplitterPanel)
// C#
SpC1.Controls.Add(new SplitterPanel());
C. ‘ VB
SpC1.Add(New SplitterPanel)
// C#
SpC1.Add(new SplitterPanel());
D. ‘ VB
None of the above
// C#
None of the above
5. Correct Answer: D
A. Incorrect. You cannot add panels to the SplitContainer control.
B. Incorrect. You cannot add panels to the SplitContainer control.
C. Incorrect. You cannot add panels to the SplitContainer control.
D. Correct. You cannot add additional panels to the SplitContainer control,
although you can add new panels to the individual SplitterPanel controls. 642-845

Leave a Reply