# Ques:
You develop a Windows-based application that includes the following code segment.
(Line numbers are included for reference only.)
01 private void Password_Validating(object sender,
02 System.ComponentModel.CancelEventArgs e)
03 {
04 if (Valid Abc Password() == false)
05 {
06 //Insert new code.
07 }
08 }
You must ensure that users cannot move control focus away from textPassword if
Valid Abc Password returns a value of False. You will add the required code on
line 6.
A. e.Cancel = true;
B. sender name;
C. password.AcceptsTab = false ;
D. password.CausesValidation = false ;
Answer: A
Explanation: If the input in the control does not fall within required parameters, the
Cancel property within your event handler can be used to cancel the Validating
event and return the focus to the control.
Reference: 70-306/70-316 Training kit, The Validating and Validated Events, Page 89
Incorrect Answers
B: Setting an object to an unknown variable is rubbish.
C: The AccptsTab property gets or sets a value indicating whether pressing the TAB key
in a multiline text box control types a TAB character in the control instead of moving the
focus to the next control in the tab order.
D: The CausesValidation property gets or sets a value indicating whether validation is
performed when the Button control is clicked.
# Ques:
You use Visual Studio .NET to create a Windows-based application. The application
includes a form named Abc Form.
Abc Form contains 15 controls that enable users to set basic configuration
options for the application.
You design these controls to dynamically adjust when users resize Abc Form.
The controls automatically update their size and position on the form as the form is
resized. The initial size of the form should be 650 x 700 pixels.
If ConfigurationForm is resized to be smaller than 500 x 600 pixels, the controls will
not be displayed correctly. You must ensure that users cannot resize
ConfigurationForm to be smaller than 500 x 600 pixels.
Which two actions should you take to configure Abc Form? (Each correct
answer presents part of the solution. Choose two)
A. Set the MinimumSize property to "500,600".
B. Set the MinimumSize property to "650,700".
C. Set the MinimizeBox property to True.
D. Set the MaximumSize property to "500,600".
E. Set the MaximumSize property to "650,700".
F. Set the MaximumBox property to True.
G. Set the Size property to "500,600".
H. Set the Size property to "650,700".
Answer: A, H
Explanation:
A: The Form.MinimumSize Property gets or sets the minimum size the form can be
resized to. It should be set to "500, 600".
H: We use the size property to set the initial size of the form. The initial size should be
set to "650, 700".
Reference:
.NET Framework Class Library, Form.MinimumSize Property [C#]
.NET Framework Class Library, Form.Size Property [C#]
Incorrect Answers
B: The initial size is 650 x 750. The minimal size should be set to "500,600".
C: The minimize button will be displayed, but it will not affect the size of the form.
D, E: There is no requirement to define a maximum size of the form.
F: The maximize button will be displayed, but it will not affect the size of the form.
G: The initial size should be 650 x 700, not 500 x 600.
# QUES:
You create a Windows Form named Abc Form. The form enables users to
maintain database records in a table named Abc .
You need to add several pairs of controls to Abc Form. You must fulfill the
following requirements:
1. Each pair of controls must represent one column in the Abc table.
2. Each pair must consist of a TextBox control and a Label control.
3. The LostFocus event of each TextBox control must call a procedure named
UpdateDatabase.
4. Additional forms similar to Abc Form must be created for other tables in the
database.
5. Application performance must be optimized.
6. The amount of necessary code must be minimized.
What should you do?
A. Create and select a TextBox control and a Label control.
Write the appropriate code in the LostFocus event of the TextBox control.
Repeatedly copy and paste the controls into Abc Form until every column in the
Abc table has a pair of controls.
Repeat this process for the other forms.
B. Add a TextBox control and a Label controls to Abc Form.
Write the appropriate code in the LostFocus event of the TextBox control.
Create a control array form the TextBox control and the Label control.
At run time, add additional pairs of controls to the control array until every column in the
Abc table has a pair of controls.
Repeat this process for the other forms.
C. Create a new user control that includes a TextBox control and a Label control.
Write the appropriate code in the LostFocus event of the TextBox control.
For each column in the Abc table, add one instance of the user control to the
Abc Form.
Repeat this process for the other forms.
D. Create a new ActiveX control that includes a TextBox control and a Label control.
For each column in the Abc table, add one instance of the ActiveX control to
Abc Form.
Repeat this process for the other forms.
Answer: C
Explanation: We combine multiple Windows Form controls into a single control,
called user control. This is the most efficient solution to reuse functionality in this
scenario.
Note: Sometimes, a single control does not contain all of the functionality you need. For
instance, you might want a control that you can bind to a data source to display a first
name, last name, and phone number, each in a separate TextBox. Although it is possible
to implement this logic on the form itself, it might be more efficient to create a single
control that contains multiple text boxes, especially if this configuration is needed in
many different applications. Controls that contain multiple Windows Forms controls
bound together as a single unit are called user controls.
Reference: 70-306/70-316 Training kit, Inheriting from UserControl, Page 345
Incorrect Answers
A: Only the controls, not the code of the control will be copied.
B: This is not the best solution. With a user control we could avoid writing code that are
executed at run time.
D: ActiveX controls should be avoided in Visual Studio .NET. They are less efficient
# QUES:
You develop a Windows control named FormattedTextBox, which will be used by
many developers in your company Abc Inc. FormattedTextBox will be updated
frequently.
You create a custom bitmap image named CustomControl.bmp to represent
FormattedTextBox in the Visual Studio .NET toolbox. The bitmap contains the
current version number of the control, and it will be updated each time the control
is updated. The bitmap will be stored in the application folder.
If the bitmap is not available, the standard TextBox control bitmap must be
displayed instead.
Which class attribute should you add to FormattedTextBox?
A. [ToolboxBitmap(typeof(TextBox))[
class FormattedTextBox
B. [ToolboxBitmap(@"CustomControl.bmp")]
class FormattedTextBox
C. [ToolboxBitmap(typeof(TextBox), "CustomControl.bmp")]
class FormattedTextBox
D. [ToolboxBitmap(typeof(TextBox))]
[ToolboxBitmap(@"CustomControl.bmp")]
class FormattedTextBox
Answer: B
Explanation: You specify a Toolbox bitmap by using the ToolboxBitmapAttribute
class. The ToolboxBitmapAttribute is used to specify the file that contains the
bitmap.
Reference: 70-306/70-316 Training kit, To provide a Toolbox bitmap for your control,
Page 355-356
Incorrect Answers
A, C, D: If you specify a Type (type), your control will have the same Toolbox bitmap as
that of the Type (type) you specify.
# QUES:
You use Visual Studio .NET to develop a Windows-based application that contains a
single form. This form contains a Label control named labelCKValue and a TextBox
control named textCKValue. labelCKValue displays a caption that identifies the
purpose of textCKValue.
You want to write code that enables users to place focus in textCKValue when they
press ALT+V. This key combination should be identified to users in the display of
labelCKValue.
Which three actions should you take? (Each correct answer presents part of the
solution. Choose three)
A. Set labelCKValue.UseMnemonic to True.
B. Set labelCKValue.Text to "&Value".
C. Set labelCKValue.CausesValidation to True.
D. Set textCKValue.CausesValidation to True.
E. Set textCKValue.TabIndex to exactly one number less than labelValue.TabIndex.
F. Set textCKValue.TabIndex to exactly one number more than labelValue.TabIndex.
G. Set textCKValue.Location so that textValue overlaps with labelValue on the screen.
H. Add the following code to the Load event of MainForm:
text.value.controls.Add (labelValue);
Answer: A, B, F
Explanation: If the UseMnemonic property is set to true (A) and a mnemonic
character (a character preceded by the ampersand) is defined in the Text property
of the Label (B), pressing ALT+ the mnemonic character sets the focus to the
control that follows the Label in the tab order (F). You can use this property to
provide proper keyboard navigation to the controls on your form.
Note1 The UseMnemonic property gets or sets a value indicating whether the control
interprets an ampersand character (&) in the control's Text property to be an access key
prefix character. UseMnemonic is set to True by default.
Note 2: As a practice verify the answer yourself.
Reference: NET Framework Class Library, Label.UseMnemonic Property [C#]
Incorrect Answers
C, D: The CausesValidation setting has no effect in this scenario.
E: The Text control must tabindex that is the successor to the tabindex of the label
control.
G, H: This is not necessary. It has no effect here.
# QUES:
You use Visual Studio .NET to create a Windows-based application called
Abc Mortage. The main form of the application contains several check boxes
that correspond to application settings. One of the CheckBox controls is named
advancedCheckBox. The caption for advancedCheckBox is Advanced.
You must enable users to select or clear this check box by pressing ALT+A.
Which two actions should you take? (Each correct answer presents part of the
solution. Choose two)
A. Set advancedCheckBox.AutoCheck to True.
B. Set advancedCheckBox.AutoCheck to False.
C. Set advancedCheckBox.Text to "&Advanced".
D. Set advancedCheckBox.Tag to "&Advanced".
E. Set advancedCheckBox.CheckState to Unchecked.
F. Set advancedCheckBox.CheckState to Indeterminate.
G. Set advancedCheckBox.Apperance to Button.
H. Set advancedCheckBox.Apperance to Normal.
Answer: A, C
Explanation:
A: The AutoCheck property must be set to True so that the CheckBox automatically is
changed when the check box is accessed.
C: The Text property contains the text associated with this control. By using the &-sign
we define a shortcut command for this control. "@Advanced" defines the shortcut
ALT+A.
Reference:
.NET Framework Class Library, CheckBox Properties
.NET Framework Class Library, CheckBox.AutoCheck Property [C#]
Incorrect Answers
B: If AutoCheck is set to false, you will need to add code to update the Checked or
CheckState values in the Click event handler.
D: The Tag property only contains data about the control.
E, F: The CheckState property only contains the state of the check box.
G, H: The appearance property only determines the appearance of a check box control.
# QUES:
Your company Abc , uses Visual Studio .NET to develop internal applications.
You create a Windows control that will display custom status bar information.
Many different developers at Abc will use the control to display the same
information in many different applications. The control must always be displayed at
the bottom of the parent form in every application. It must always be as wide as the
form. When the form is resized, the control should be resized and repositioned
accordingly.
What should you do?
A. Create a property to allow the developers to set the Dock property of the control.
Set the default value of the property to AnchorStyle.Bottom.
B. Create a property to allow the developer to set the Anchor property of the control.
Set the default value of the property to AnchorStyle.Bottom.
C. Place the following code segment in the UserControl_Load event:
this.Dock = DockStyle.Bottom;
D. Place the following code segment in the UserControl_Load event:
this.Anchor = AnchorStyle.Bottom;
Answer: C
Explanation:
DockStyle.Bottom docks the control to the bottom of the form. This will force the control
to be as wide as to form. Furthermore the control will be resized automatically.
Reference:
Visual Basic and Visual C# Concepts, Aligning Your Control to the Edges of Forms
NET Framework Class Library, AnchorStyles Enumeration [C#]
Incorrect Answers
A: There is no need to the other developers to set the Dock property.
B: The Dock property should be used.
D: The Anchorstyle class specifies how a control anchors to the edges of its container.
Not how a control is docked.
# QUES:
As a software developer at Abc inc. you use Visual Studio .NET to create a
Windows-based application. You need to make the application accessible to users
who have low vision. These users navigate the interface by using a screen reader,
which translates information about the controls on the screen into spoken words.
The screen reader must be able to identify which control currently has focus.
One of the TextBox controls in your application enables users to enter their names.
You must ensure that the screen reader identifies this TextBox control by speaking
the word "name" when a user changes focus to this control.
Which property of this control should you configure?
A. Tag
B. Next
C. Name
D. AccessibleName
E. AccessibleRole
Answer: D
Explanation: The AccessibleName property is the name that will be reported to the
accessibility aids.
Reference:
Visual Basic and Visual C# Concepts, Providing Accessibility Information for Controls
on a Windows Form
Visual Basic and Visual C# Concepts, Walkthrough: Creating an Accessible Windows
Application
Incorrect Answers
A, B, C: The Tag, Next and Name properties of a control is not used directly by
accessibility aids.
E: The AccessibleRole property describes the use of the element in the user interface.
# QUES:
You use Visual Studio .NET to create a Windows-based application. The application
includes a form named Xyz Form, which displays statistical date in graph format.
You use a custom graphing control that does not support resizing.
You must ensure that users cannot resize, minimize, or maximize Xyz Form.
Which three actions should you take? (Each answer presents part of the solution.
Choose three)
A. Set Xyz Form.MinimizeBox to False.
B. Set Xyz Form.MaximizeBox to False.
C. Set Xyz Form.ControlBox to False.
D. Set Xyz Form.ImeMode to Disabled.
E. Set Xyz Form.WindowState to Maximized.
F. Set Xyz Form.FormBorderStyle to one of the Fixed Styles.
G. Set Xyz Form.GridSize to the appropriate size.
Answer: A, B, F
Explanation: We disable the Minimize and Maximize buttons with the
Xyz Form.Minimizebox and the Xyz Form.Maximizebox properties.
Furthermore we should use a fixed FormBorderStyle to prevent the users from
manually resizing the form.
Reference:
Visual Basic and Visual C# Concepts, Changing the Borders of Windows Forms
.NET Framework Class Library, Form.MinimizeBox Property [C#]
.NET Framework Class Library, Form.MaximizeBox Property [C#]
# QUES:
You use Visual Studio .NET to create a Windows-based application for Abc
Inc. The application includes a form that contains several controls, including a
button named exitButton. After you finish designing the form, you select all controls
and then select Lock Controls from the Format menu.
Later, you discover that exitButton is too small. You need to enlarge its vertical
dimension with the least possible effort, and without disrupting the other controls.
First you select exitButton in the Windows Forms Designer. What should you do
next?
A. Set the Locked property to False.
Set the Size property to the required size.
Set the Locked property to True.
B. Set the Locked property to False.
Use the mouse to resize the control.
Set the Locked property to True.
C. Set the Size property to the required size.
D. Use the mouse to resize the control.
Answer: C
# QUES:
You develop a Visual Studio .NET application that dynamically adds controls to its
form at run time. You include the following statement at the top of your file:
using System.windows.Forms;
In addition, you create the following code to add Button controls:
Button tempButton = new Button ( ) ; tempButton.Text =
NewButtonCaption; tempButton.Name = NewButtonName;
tempButton.Left = NewButtonLeft; tempButton.Top=
NewButtonTop; this.Controls.Add (tempButton) ;
tempButton.Click += new EventHnadler (ButtonHnadler) ;
Variables are passed into the routine to supply values for the Text, Name, Left, and
Top properties.
When you compile this code, you receive an error message indicating that
ButtonHandler is not declared.
You need to add a ButtonHandler routine to handle the Click event for all
dynamically added Button controls.
Which declaration should you use for ButtonHandler?
A. public void ButtonHandler()
B. public void ButtonHandler(System.Windows.Forms.Button
sender)
C. public void ButtonHandler(System.Object sender)
D. public void ButtonHandler(System.Windows.Forms.Button
sender, System.EventArgs e)
E. public void ButtonHandler(System.Object sender,
System.EventArgs e)
Answer: E
# QUES:
You develop an application that enables users to enter and edit purchase order
details. The application includes a Windows Form named Display Abc Form.
The application uses a client-side DataSet object to manage data.
The DataSet object contains a Data Table object named Abc Details. This
object includes one column named Quantity and another named UnitPrice. For each
item on a purchase order, your application must display a line item total in a
DataGrid control on Display Abc Form. The line item is the product of Quantity
times UnitPrice. Your database design does not allow you to store calculated values
in the database.
You need to add code to your Form_Load procedure to calculate and display the
line item total.
Which code segment should you use?
A. DataColumn totalColumn =
new DataColumn ("Total", Type.GetType ("system.Decimal ") ) ;
Abc.Columns.Add (totalColumn;
totalColumn.Expression = "Quantity * UnitPrice";
B. DataColumn totalColumn =
New DataColumn ("Total", Type.GetType ("system.Decimal ") ) ;
Abc.Columns.Add (totalColumn;
totalColumn.Equals = ("Quantity * UnitPrice")
C. AbcDetails.DisplayExpression ( Quantity * UnitPrice";
D. Abc Details.DisplayExpression("quantityColumn *
unitpriceColum" } ;
Answer: A
Explanation: We use the Expression property of the DataColumn object calculate
the values in the column.
Reference:
.NET Framework Developer's Guide, Creating Expression Columns [C#]
.NET Framework Class Library, DataColumn Class [C#]
.NET Framework Class Library, Object.Equals Method (Object) [C#]
.NET Framework Class Library, DataTable.DisplayExpression Property [C#]
Incorrect Answers
B: The Equals method cannot be used in this way. The equals method is used to test if
different objects are equal.
C, D: The DisplayedExpression would be set to a string value, not a calculated value.
# QUES:
As a software developer at Abc you create a user control named ScrollControl,
which you plan to sell to developers. You want to ensure that ScrollControl can be
used only by developers who purchase a license to use it.
You decide to use a license provider implemented by the LicFileLicenseProvider
class. Now you need to add code to ScrollControl to test for a valid control license.
Which two code segments should you add? (Each correct answer presents part of
the solution. Choose two)
A. [LicenseProvider(typeof(LicFileLicenseProvider))]
B. [LicenseProvider(typeof(ScrollControl))]
C. In the Load event handler for ScrollControl, place the following code segment:
License controlLicense; try { controlLicense =
LicenseManager.Validate( typeof(ScrollControl)) : } catch
(Exception exp) { // Insert code to disallow use. }
D. In the Load event handler for ScrollControl, place the following code segment:
License controlLicense; try { controlLicense =
LicenseManager.Validate( typeof(ScrollControl)) , this }; }
catch (Exception exp) { // Insert code to disallow use. }
E. In the Load event handler for ScrollControl, place the following code segment:
Bool blicensed; try { blicensed =
LicenseManager.IsValid (Typeof (scrollControl) } ; } catch
(Exception exp) { // Insert code to disallow use. }
F. In the Load event handler for ScrollControl, place the following code segment:
LicenseManager.IsValid( typeof(ScrollControl), this,
to disallow use. }
Answer: A, D
.
# QUES:
You use Visual Studio .NET to create a Windows-based application for online
gaming. Each user will run the client version of the application on his or her local
computer. In the game, each user controls two groups of soldiers, Group1 and
Group2.
You create a top-level menu item whose caption is Groups. Under this menu, you
create two submenus. One is named group1Submenu, and its caption is Group 1.
The other is named group2Submenu, and its caption is Group 2. When the user
select the Groups menu, the two submenus will be displayed. The user can select
only one group of soldiers at a time.
You must ensure that a group can be selected either by clicking the appropriate
submenu item or by holding down the ALT key and pressing 1 or 2. You must also
ensure that the group currently select will be indicated by a dot next to the
corresponding submenu item. You do not want to change the caption text of any of
your menu items.
Which four actions should you take? (Each correct answer presents part of the
solution. Choose four)
A. Set group1Submenu.Text to "Group &1".
Set group2Submenu.Text to "Group &2".
B. Set Group1.ShortCut to "ALT1".
Set Group2.ShortCut to "ALT2".
C. In the group1Submenu.Click event, place the following code segment:
group1submenu.Defaultitem = true;
In the group2Submenu.Click event, place the following code segment:
group2submenu.Defaultitem = true;
D. In the group1Submenu.Click event, place the following code segment:
grouplsubmenu.Defaultitem = false;
In the group2Submenu.Click event, place the following code segment:
grouplsubmenu.Defaultitem = false;
E. In the group1Submenu.Click event, place the following code segment:
grouplsubmenu.Checked = true;
In the group2Submenu.Click event, place the following code segment:
group2submenu.Checked = true;
F. In the group1Submenu.Click event, place the following code segment:
group2subemnu.Checked = false;
In the group2Submenu.Click event, place the following code segment:
group2subemnu.Checked = false;
G. Set group1Submenu.RadioCheck to True.
Set group2Submenu.RadioCheck to True.
H. Set group1Submenu.RadioCheck to False.
Set group2Submenu.RadioCheck to False.
Answer: B, E, F, G
Explanation:
B: Simply set the Group1.Shortcut to appropriate value.
E, F: The menu item's Checked property is either true or false, and indicates whether the
menu item is selected. We should set the clicked Submenu Checked property to True, and
the other Submenu Checked property to False.
G: The menu item's RadioCheck property customizes the appearance of the selected
Reference:
Visual Basic and Visual C# Concepts, Adding Menu Enhancements to Windows Forms
Visual Basic and Visual C# Concepts, Introduction to the Windows Forms MainMenu
Component
Incorrect Answers
A: You do not want to change the caption text of any of your menu items.
C, D: We are not interested in defining default items. We want to mark items as checked.
H: The RadioCheck property must be set to True for both menu items.
# QUES:
You work as a software developer at Abc .com. You application uses a DataSet
object to maintain a working set of data for your users. Users frequently change
information in the DataSet object. Before you update your database, you must run
data validation code on all user changes.
You need to identify the data rows that contain changes. First you create a
DataView object.
What should you do next?
A. Set the RowStateFilte.CompareTo method.
B. Set the RowStateFilter.Equals method.
C. Set the RowStateFilter property to CurrentRows.
D. Set the RowStateFilter property to ModifiedCurrent.
Answer: D
Correct answer is "Set the RowStateFilter property to
ModifiedCurrent", this will shows changed rows and the current values.
# QUES:
You develop a Windows-based orderentry application Abc App. The
application uses a DataSet object named customerDataSet to manage client data
while users edit and update customer records. The DataSet object contains a
DataTable object named creditAuthorizationDataTable. This object contains a field
named MaxCredit, which specifies the credit limit for each customer.
Customer credit limits cannot exceed $20,000. Therefore, Abc App must verify
that users do not enter a larger amount in MaxCredit. If a user does so, the user
must be notified, and the error must be corrected, before any changes are stored
permanently in the database.
You create a procedure named OnRowChanged. This procedure sets the
DataTable.Row.RowError property for each row that includes an incorrect credit
limit. You also enable the appropriate event handling so OnRowChanged is called in
reaction to the RowChanged event of the DataTable object. OnRowChanged will
run each time a user changes data in a row.
OnRowChanged contains the following code segment:
private sender, DataRowChanged(
Object sender, DataRowChangeEventArgs e) {
if ((double) e.Row["MaxCKCredit"] > 20000) {
e.Row.RowError = "Over credit limit. " ;
}
}
Before updating the database, your application must identify and correct all rows
that are marked as having an error. Which code segment should you use?
A. foreach (DataRow myRow in
creditAuthorizationDataTable.GetErrors()) {
MessageBox.Show(
String.Format("CustID = {0}, Error = {1}",
MyRow["CustID"] . myRow.RowError) ) ;
}
B. foreach (DataRow myRow in
creditAuthorizationDataTable.HasErrors()) {
MessageBox.Show(
String.Format("CustID = {0}, Error = {1}",
MyRow [ ; CustID"], myRow.RowError) ) ;
}
C. DataView vw = new DataView(
customerDataSet.Tables["creditAuthorizationDataTable"],
DataViewRowstate.ModifiedCurrent) ;
MessageBox.Show(
D. DataView vw = new DataView(
customerDataSet.Tables["creditAuthorizationDataTable"],
MessageBox.Show(
Answer: A
Explanation: GetErrors method gets an array of DataRow objects that contain
errors. We use the GetErrors method to get retrieve all rows that contain errors.
Reference: .NET Framework Class Library, DataRow.RowError Property [C#]
Incorrect Answers
B: The HasErrors property is used to determine if a DataRow contains errors. It returns a
Boolean value, not an array of DataRow objects.
C: We don't want to access the current version the rows, just the rows that contain errors.
D: We don't want to access the original version the rows, just the rows that contain
errors.
# QUES:
You develop a Windows-based application Abc App that includes several
menus. Every top-level menu contains several menu items, and certain menus
contain items that are mutually exclusive. You decide to distinguish the single most
important item in each menu by changing its caption text to bold type.
What should you do?
A. Set the DefaultItem property to True.
B. Set the Text property to "True".
C. Set the Checked property to True.
D. Set the OwnerDraw property to True.
Answer: A
Explanation: Gets or sets a value indicating whether the menu item is the default
menu item. The default menu item for a menu is boldfaced.
Reference: .NET Framework Class Library, MenuItem.DefaultItem Property [C#]
Incorrect Answers
B: The Text property contains the text that is associated with the control. We cannot
format this text by HTML-like tags in the text.
C: We don't want the menu-item to be selected, just bold.
D: When the OwnerDraw property is set to true, you need to handle all drawing of the
menu item. You can use this capability to create your own special menu displays
# QUES:
You use Visual Studio .NET to create a data entry form. The form enables users to
edit personal information such as address and telephone number. The form contains
a text box named textPhoneNumber.
If a user enters an invalid telephone number, the form must notify the user of the
error. You create a function named IsValidPhone that validates the telephone
number entered. You include an ErrorProvider control named ErrorProvider1 in
your form.
Which additional code segment should you use?
A. private void textPhone_Validating(
object sender, System.ComponentModel.CancelEventArgs e) {
if (!IsValidPhone()) {
errorProviderl.SetError (TextPhone,"Invalid Phone.");
}
}
B. private void textPhone_Validated(
object sender, System.EventArgs e) {
if (!IsValidPhone()) {
errorProviderl.SetError (TextPhone,"Invalid Phone.");
}
}
C. private void textPhone_Validating(
object sender, System.ComponentModel.CancelEventArgs e) {
if (!IsValidPhone()) {
errorProviderl.GetError (textPhone Phone);
}
}
D. private void textPhone_Validated(
object sender, System.EventArgs e) {
if (!IsValidPhone()) {
errorProviderl.GetError (textPhone Phone);
}
}
E. private void textPhone_Validating(
object sender, System.ComponentModel.CancelEventArgs e) {
if (!IsValidPhone()) {
errorProviderl.(UpdateBinding ();
}
}
F. private void textPhone_Validated(
object sender, System.EventArgs e) {
if (!IsValidPhone()) {
errorProviderl.(UpdateBinding ();
}
}
Answer: A
Explanation: The Validating event allows you to perform sophisticated validation
on controls. It is possible to use an event handler that doesn't allow the focus to
leave the control until a value has been entered.
The ErrorProvider component provides an easy way to communicate validation errors to
users. The SetError method of the ErrorProvider class sets the error description string for
the specified control.
Note: Focus events occur in the following order:
1. Enter
2. GotFocus
3. Leave
4. Validating
5. Validated
6. LostFocus
Reference: 70-306/70-316 Training kit, To create a validation handler that uses the
ErrorProvider component, Pages 93-94
.NET Framework Class Library, ErrorProvider.SetError Method [C#]
Incorrect Answers
C: The GetError method returns the current error description string for the specified
control.
E: The updateBinding method provides a method to update the bindings of the
DataSource, DataMember, and the error text. However, we just want to set the error
description.
B, D, F: The validated event occurs when the control is finished validating. It can used to
perform any actions based upon the validated input.
# QUES:
You work as a software developer at Abc .com. You develop a Windows-based
application that includes two objects named Abc Contact and
Abc Employee. Abc Employee inherits from Abc Contact, and
Abc Contact exposes an event named DataSaved. You want to raise the
DataSaved event from Abc Employee.
What should you do?
A. Call the RaiseEvent method from Abc Employee and pass DataSaved as the event
name.
B. Add the Public keyword to the DataSaved declaration in Abc Contact.
Call the RaiseEvent method from Abc Employee.
C. In Abc Contact, create a protected method named RaiseDataSaved that explicitly
raises the DataSaved event.
Call RaiseDataSaved from Abc Employee.
D. In Abc Employee, create a protected method named RaiseDataSaved that
explicitly raises the DataSaved event in Abc Contact.
Call RaiseDataSaved to fire the event.
Answer: A
# QUES:
You use Visual Studio .NET to develop a Windows-based application. The
application includes several menu controls that provide access to most of the
application's functionality.
One menu option is named calculateOption. When a user chooses this option, the
application will perform a series of calculations based on information previously
entered by the user.
To provide user assistance, you create a TextBox control named Abc Help. The
corresponding text box must display help information when the user pauses on the
menu option with a mouse or navigates to the option by using the arrow keys.
You need to add the following code segment:
Abc Help.Text = "This menu option calculates the
In which event should you add this code segment?
A. calculateOption_Click
B. calculateOption_Popup
C. calculateOption_Select
D. calculateOption_DrawItem
E. calculateOption_MeasureItem
Answer: C
Explanation: The Select event is raised when a menu item is highlighted. We should
use the Select event to set the helper text.
Reference: 70-306/70-316 Training kit, Using Menu Item Events, Page 79
Incorrect Answers
A: The Click event occurs when a menu item is selected.
B: The Popup event is raised just before a menu item's list of menu items is displayed. It
can be used to enable and disable menu items at run time before the menu is displayed.
D: The DrawItem event handler provides a Graphics object that enables you to perform
drawing and other graphical operations on the surface of the menu item.
E: The MeasureItem event occurs when the menu needs to know the size of a menu item
before drawing it.
# QUES:
You develop a Windows-based application that will retrieve Abc employee
vacation data and display it in a DataGrid control. The data is managed locally in a
DataSet object named employeeDataSet.
You need to write code that will enable users to sort the data by department.
Which code segment should you use?
A. DataView dvDept = new DataView(); dvDept.Table =
employeeDataSet.Tables[0]; dvDept.Sort = "ASC";
DataGrid1.DataSource = dvDept;
B. DataView dvDept = new DataView(); dvDept.Table =
employeeDataSet.Tables[0]; dvDept.Sort = "Department";
DataGrid1.DataSource = dvDept;
C. DataView dvDept = new DataView(); dvDept.Table =
employeeDataSet.Tables[0]; dvDept.ApplyDefaultSort = true;
DataGrid1.DataSource = dvDept;
D. DataView dvDept = new DataView(); dvDept.Table =
employeeDataSet.Tables[0]; dvDept.ApplyDefaultSort = false;
DataGrid1.DataSource = dvDept;
Answer: B
# QUES:
You develop a Windows-based application to manage business contacts. The
application retrieves a list of contacts from a central database. The list is managed
locally in a DataSet object named listDataSet, and it is displayed in a DataGrid
control.
You create a procedure that will conduct a search after you enter a combination of
personal name and family name. You application currently includes the following
code segment:
DataView dv = new DataView();
int i;
dv.Table = listDataSet.Tables(0);
dv.Sort = "FamilyName, PersonalName";
DataGrid1.DataSource = dv;
You need to search for a conduct whose personal name is Jack and whose family
name is Bill. Which code segment should you use?
A. object[] values = {"Bill", "Jack"};
i = dv.Find(values);
DataGrid1.CurrentRowIndex = i;
B. object() values = {"Bill, Jack"};
i = dv.Find(values);
DataGrid1.CurrentRowIndex = i;
C. object[] values = {"Jack", "Bill"};
i = dv.Find(values);
DataGrid1.CurrentRowIndex = i;
D. object[] values = {"Jack, Bill"};
i = dv.Find(values);
DataGrid1.CurrentRowIndex = i;
Answer: A
Explanation: We load the search parameters into an array. We use two separate
values. The first value is the FamilyName and the second is PersonalName as it is
used in the sort command:
dv.Sort = "FamilyName, PersonalName"
The family name is Bill. The personal name is Jack.
Reference: 70-306/70-316 Training kit, Filtering and Sorting in a DataSet, Page 306
Incorrect Answers
B, D: There are two columns. We must separate the Family name and the Personal into
two separate strings.
C: Wrong order of the search parameters. The family name Bill must be the first search
parameter.
# QUES:
You use Visual Studio .NET to create a Windows-based application. On the main
application form, Abc FormMain, you create a TextBox control named
textConnectionString. Users can enter a database connection string in this box to
access customized data from any database in your company.
You also create a Help file to assist users in creating connection strings. The Help
file will reside on your company intranet.
Your application must load the Help file in a new browser window when the user
presses F1 key, but only of textConnectionString has focus. You must create this
functionality by using the minimum amount of code.
In which event should you write the code to display the Help file?
A. textConnectionString_KeyPress
B. textConnectionString_KeyDown
C. textConnectionString_KeyUp
D. textConnectionString_GiveFeedback
E. textConnectionString.HelpReabcted
Answer: E
Explanation:
The Control.HelpReabcted Event occurs when the user reabcts help for a control.
The HelpReabcted event is commonly raised when the user presses the F1 key or
an associated context-sensitive help button is clicked. This would be the most
straightforward solution and would require minimal code.
Note: Key events occur in the following order:
1. KeyDown
2. KeyPress
3. KeyUp
Reference:
.NET Framework Class Library, Control.HelpReabcted Event [C#]
.NET Framework Class Library, Control.KeyDown Event [C#]
Incorrect Answers
A: The KeyPress event occurs when a key is pressed while the control has focus. The
KeyPress event could be used to provide a solution, but it would require more code.
B: The KeyDown event occurs when a key is pressed while the control has focus.
C: The KeyUp occurs when a key is released while the control has focus.
D: The Control.GiveFeedback does not apply here. It occurs during a drag operation.
# QUES:
You use Visual Studio .NET to create a Windows-based application. The application
captures screen shots of a small portion of the visible screen.
You create a form named Abc CameraForm. You set the
Abc CameraForm.BackColor property to Blue. You create a button on the
form to enable users to take a screen shot.
Now, you need to create a transparent portion of Abc CameraForm to frame a
small portion of the screen. Your application will capture an image of the screen
inside the transparent area. The resulting appearance of Xyz i ngCameraForm is
shown in the exhibit:
You add a Panel control to Abc CameraForm and name it transparentPanel.
You must ensure that any underlying applications will be visible within the panel.
Which two actions should you take? (Each correct answer presents part of the
solution. Choose two.)
A. Set transparentPanel.BackColor to Red.
B. Set transparentPanel.BackColor to Blue.
C. Set transparentPanel.BackgroundImage to None.
D. Set transparentPanel.Visible to False.
E. Set Abc CameraForm.Opacity to 0%.
F. Set Abc CameraForm.TransparencyKey to Red.
G. Set Abc CameraForm.TransparencyKey to Blue.
Answer: A, F
Explanation:
A: We set the Background color of the Panel to Red.
F: We then the transparency color of the Form to Red as well.
This will make only the Panel transparent, since the background color of the form is
Blue.
# QUES:
You work as software developer at Abc inc. You need to develop a Windows
form that provides online help for users. You want the help functionality to be
available when users press the F1 key. Help text will be displayed in a pop-up
window for the text box that has focus.
To implement this functionality, you need to call a method of the HelpProvider
control and pass the text box and the help text.
What should you do?
A. SetShowHelp
B. SetHelpString
C. SetHelpKeyword
D. ToString
Answer: B
Explanation:
To associate a specific Help string with another control, use the SetHelpString
method. The string that you associate with a control using this method is displayed
in a pop-up window when the user presses the F1 key while the control has focus.
Reference: Visual Basic and Visual C# Concepts, Introduction to the Windows Forms
HelpProvider Component
# QUES:
You develop a Windows-based application. Its users will view and edit employee
attendance data. The application uses a DataSet object named customerDataSet to
maintain the data while users are working with it.
After a user edits data, business rule validation must be performed by a middle-tier
component named Xyz Component. You must ensure that your application sends
only edited data rows from customDataSet to Xyz Component.
Which code segment should you use?
A. DataSet changeDataSet = new DataSet(); if
(customDataSet.HasChanges) {
Xyz Component.Validate(changeDataSet); }
B. DataSet changeDataSet = new DataSet(); if
(customDataSet.HasChanges) {
Xyz Component.Validate(customDataSet); }
C. DataSet changeDataSet = customDataSet.GetChanges();
Xyz Component.Validate(changeDataSet);
D. DataSet changeDataSet = customDataSet.GetChanges();
Xyz Component.Validate(customDataSet);
Answer: C
# QUES:
You use Visual Studio .NET to develop a Windows-based application. Your
application will display customer order information from a Microsoft SQL Server
database. The orders will be displayed on a Windows Form that includes a
DataGrid control named Abc Grid1. Abc Grid1 is bound to a DataView
object. Users will be able to edit order information directly in Abc Grid1.
You must give users the option of displaying only edited customer orders and
updated values in Abc Grid1.
What should you do?
A. Set the RowStateFilter property of the DataView object to
DataViewRowState.ModifiedOriginal.
B. Set the RowStateFilter property of the DataView object to
DataViewRowState.ModifiedCurrent.
C. Set the RowFilter property of the DataView object to
DataViewRowState.ModifiedOriginal.
D. Set the RowFilter property of the DataView object to
DataViewRowState.ModifiedCurrent.
Answer: B
Explanation: We must set the RowStateFilter property of the DataView to specify
which version or versions of data we want to view. We should use the
ModifiedCurrent. DataViewRowState which provides the modified version of
original data.
Reference:
.NET Framework Class Library, DataViewRowState Enumeration [C#]
Incorrect Answers
A, C: The ModifiedOriginal DataViewRowState is used to get the original version of the
rows in the view. We are interested in the modified rows however.
D: We are not applying an usual filter with the RowFilter property. We must use a
RowStateFilter.
# QUES:
As a developer at Abc you develop a new salesanalysis application that reuses
existing data access components. One of these components returns a DataSet object
that contains the data for all customer orders for the previous year.
You want your application to display orders for individual product numbers. Users
will specify the appropriate product numbers at run time.
What should you do?
A. Use the DataSet.Reset method.
B. Set the RowFilter property of the DataSet object by using a filter expression.
C. Create a DataView object and set the RowFilter property by using a filter expression.
D. Create a DataView object and set the RowStateFilter property by using a filter
expression.
Answer: C
Explanation: You filter data by setting the RowFilter property. The RowFilter
property takes a String that can evaluate to an expression to be used for selecting
records. RowFilter is a property of the DataView object.
Reference: Visual Basic and Visual C# Concepts, Filtering and Sorting Data Using Data
Views
Incorrect Answers
A: The DataSet-Reset method resets the DataSet to its original state.
B: RowFilter is not a property of the DataSet object.
D: The RowStateFilter property is used to filter based on a version or state of a record.
Filter expressions cannot be used on RowStateFilters. The RowStates are Added,
CurrentRows, Deleted, ModifiedCurrent, ModifiedOriginal, None, OriginalRows, and
Unchanged.
# QUES:
You develop a Windows-based application Xyz . Xyz uses a DataSet object that
contains two DataTable objects. Xyz will display data from two data tables. One
table contains customer information, which must be displayed in a data-bound
ListBox control. The other table contains orderinformation, which must be
displayed in a DataGrid control.
You need to modify Xyz to enable the list box functionality.
What should you do?
A. Use the DataSet.Merge method.
B. Define primary keys for the Data Table objects.
C. Create a foreign key constraint on the DataSet object.
D. Add a DataRelation object to the Relations collection of the DataSet object.
Answer: D
Explanation: You can use a DataRelation to retrieve parent and child rows. Related
rows are retrieved by calling the GetChildRows or GetParentRow methods of a
DataRow.
Note: A DataRelation object represents a relationship between two columns of data in
different tables. The DataRelation objects of a particular DataSet are contained in the
Relations property of the DataSet. A DataRelation is created by specifying the name of
the DataRelation, the parent column, and the child column.
Reference: 70-306/70-316 Training kit, Retrieving Related Records, Page 286
Incorrect Answers
A: The Merge method is used to merge two DataSet objects that have largely similar
schemas. A merge does not meet the requirements of the scenario however.
B: Primary keys would not help relating the DateTable objects.
C:
Foreign key constraints put restrictions on the data in two different tables. However, it
would not help in retrieving related records.
# QUES:
You develop a Windows-based application to manage business contacts. The
application retrieves a list of contacts from a central database called Abc DB.
The list of contacts is managed locally in a DataSet object named contactDataSet.
To set the criteria for retrieval, your user interface must enable users to type a city
name into a TextBox control.
The list of contacts that match this name must then be displayed in a DataGrid
control.
Which code segment should you use?
A. DataView contactDataSet = new DataView();
dv.Table = contactDataSet.Tables[0];
dv.RowFilter = TextBox1.Text;
DataGrid1.DataSource = dv;
B. DataView dv = new DataView();
dv.Table = contactDataSet.Tables[0];
dv.RowFilter =
String.Format("City = '{0}'", TextBox1.Text);
DataGrid1.DataSource = dv;
C. DataView contactDataSet = new DataView();
dv.Table = contactDataSet.Tables[0];
dv.Sort = TextBox1.Text;
DataGrid1.DataSource = dv;
D. DataView dv = new DataView();
dv.Table = contactDataSet.Tables[0];
dv.Sort =
String.Format("City = '{0}'", TextBox1.Text);
Answer: B
Explanation: To form a RowFilter value, specify the name of a column followed by
an operator and a value to filter on. The value must be in quotes. Here we use
construct the rowfilter with the = operator, string concatenation (&) and the
TextBox1.Text property.
Reference: .NET Framework Class Library, DataView.RowFilter Property [C#]
Incorrect Answers
A: We must use the = operator and construct an expression. We cannot just use a value.
C, D: We want to filter the Dataset, not to sort it.
# QUES:
You use Visual Studio .NET to develop a Windows-based application that interacts
with a Microsoft SQL Server database. Your application contains a form named
CustomerForm. You add the following design-time components to the form:
1. SqlConnection object named Abc Connection.
2. SqlDataAdapter object named Abc DataAdapter.
3. DataSet object named Abc DataSet.
4. Five TextBox controls to hold the values exposed by Abc DataSet.
At design time, you set the DataBindings properties of each TextBox control to the
appropriate column in the DataTable object of Abc DataSet. When you test the
application, you can successfully connect to the database. However, no data is
displayed in any text boxes.
You need to modify your application code to ensure that data is displayed
appropriately. Which behavior should occur while the CustomerForm.Load event
handler is running?
A. Execute the Add method of the TextBoxes DataBindings collection and pass in
Abc DataSet.
B. Execute the BeginInit method of Abc DataSet.
C. Execute the Open method of Abc Connection.
D. Execute the FillSchema method of Abc DataAdapter and pass in
Abc DataSet.
E. Execute the Fill method of Abc DataAdapter and pass in Abc DataSet.
Answer: E
Explanation: Dataset is a container; therefore, you need to fill it with data. You can
populate a dataset by calling the Fill method of a data adapter.
Reference: Visual Basic and Visual C# Concepts, Introduction to Datasets
# QUES:
You use Visual Studio .NET to create a Windows Form named Abc Form. You
add a custom control named BarGraph, which displays numerical data. You create
a second custom control named DataBar. Each instance of DataBar represents one
data value in BarGraph.
BarGraph retrieves its data from a Microsoft SQL Server database. For each data
value that it retrieves, a new instance of DataBar is added to BarGraph. BarGraph
also includes a Label control named DataBarCount, which displays the number of
DataBar controls currently contained by BarGraph.
You must add code to one of your custom controls to ensure that DataBarCount is
always updated with the correct value.
What are two possible ways to achieve this goal? (Each correct answer presents a
complete solution. Choose two)
A. Add the following code segment to the ControlAdded event handler for DataBar:
this.DataBarCount.Text = this.Controls.Count;
B. Add the following code segment to the ControlAdded event handler for DataBar:
this.DataBarCount.Text = Parent.Controls.Count;
C. Add the following code segment to the ControlAdded event handler for BarGraph:
DataBarCount.Text = this.Controls.Count;
D. Add the following code segment to the constructor for BarGraph:
this.Parent.DataBarCount.Text = this.Controls.Count;
E. Add the following code segment to the constructor for DataBar:
this.Parent.DataBarCount.Text = this.Controls.Count;
F. Add the following code segment to the AddDataPoint method of BarGraph:
DataBarCount.Text = this.Parent.Controls.Count;
Answer: C, E
Explanation: We could either catch the ControlAdded event, or add code the
constructor.
C: The Control.ControlAdded Event occurs when a new control is added to the
Control.ControlCollection. When a control is added to BarGraph we could set the count
of controls to the number of current controls in BarGraph.
E: Every time a new DataBar is constructed we could set the counter.
Reference: .NET Framework Class Library, Control.ControlAdded Event [C#]
Incorrect Answers
A, B: Controls are added to BarGraph not to the DataBar.
D: DataBars, not BarGraphs, are constructed.
F: The AddDataPoint method does not apply.
# QUES:
You use Visual Studio .NET to develop a Microsoft Windows-based application.
Your application contains a form named CustomerForm, which includes the
following design-time controls:
1. SQLConnection object named Abc Connection
2. SQLDataAdapter object named Abc DataAdapter
3. DataSet object named CustomerDataSet
4. Five TextBox controls to hold the values exposed by CustomerDataSet
5. Button control named saveButton
At design time you set the DataBindings properties of each TextBox control to the
appropriate column in the DataTable object of CustomerDataSet.
When the application runs, users must be able to edit the information displayed in
the text boxes. All user changes must be saved to the appropriate database when
saveButton is executed. The event handler for saveButton includes the following
code segment:
Abc DataAdapter.Update(CustomerDataSet);
You test the application. However, saveButton fails to save any values edited in the
text boxes.
You need to correct this problem.
What should your application do?
A. Call the InsertCommand method of Abc DataAdapter.
B. CALL THE Update method of Abc DataAdapter and pass in
Abc Connection.
C. Before calling the Update method, ensure that a row position change occurs in
CustomerDataSet.
D. Reestablish the database connection by calling the Open method of
Abc Connection.
Answer: C
Explanation:
Not B: There is no connection parameter in the Update method of the DataAdapter class.
Reference:
Visual Basic and Visual C# Concepts, Dataset Updates in Visual Studio .NET
.NET Framework Class Library, SqlDataAdapter Constructor (String, SqlConnection)
[C#]
# QUES:
You development team at Abc .com is using Visual Studio .NET to create an
accounting application, which contains a substantial amount of code. Sometimes a
developer cannot complete a portion of code until dependencies are completed by
another developer. In these cases, the developer adds a comment in the application
code about the work left incomplete. Such comments always begin with the
UNDONE.
You open the application code on your computer. As quickly as possible, you need
to view each comment that indicates incomplete work.
What should you do?
A. Configure the Task List window to show all tasks.
B. Use the Build Comment Web Pages dialog box to build Comment Web Pages for the
entire solution.
C. Open a code window and use the Find in Files dialog box to search the application
code for UNDONE.
D. Open a code window and use the Find dialog box to search all open documents for
UNDONE.
Answer: A
Explanation:
A is a much easier solution. B provides no more information but takes longer to use.
# QUES:
You develop a Windows-based application named Abc 3 by using Visual Studio
.NET. Abc 3 consumes an XML Web service named MortgageRate and exposes
a method named GetCurrentRate. Abc 3 uses GetCurrentRate to obtain the
current mortgage interest rate.
Six months after you deploy Abc 3, users begin reporting errors. You discover
that MortgageRate has been modified. GetCurrentRate now requires you to pass a
postal code before returning the current mortgage interest rate.
You must ensure that Abc 3 consumes the most recent version of
MortgageRate. You must achieve this goal in the most direct way possible.
What should you do?
A. Use Disco.exe to generate a new proxy class for MortgageRate.
B. Modify the Abc 3 code to pass the postal code to GetCurrentRate.
C. Use the Update Web Reference menu item to update the reference to MortgageRate in
Abc 3.
D. Use the Add Reference dialog box to recreate the reference to MortgageRate in
Abc 3.
E. Remove the reference to MortgageRate in Abc 3. Use the Add Web Reference
dialog box to create the reference.
Answer: C
Explanation: If your application contains a Web reference to an XML Web service
that has been recently modified on the server, you may need to update the reference
in your project.
To update a project Web reference
1. In Solution Explorer, access your project's Web References folder and select the node
for the Web reference you want to update.
2. Right-click the reference and click Update Web Reference.
Reference: Visual Basic and Visual C# Concepts, Managing Project Web References
# QUES:
You use Visual Studio .NET to create an assembly, called Abc Assembly, that
will be used by other applications, including a standard COM client application.
You must deploy your assembly on the COM application to a client computer. You
must ensure that the COM application can instantiate components within the
assembly as COM components.
What should you do?
A. Create a strong name of the assembly by using the Strong Name tool (Sn.exe).
B. Generate a registry file for the assembly by using the Assembly Registration tool
(Regasm.exe)
Register the file on the client computer.
C. Generate a type library for the assembly by using the Type Library Importer
(Tlbimp.exe).
Register the file on the client computer.
D. Deploy the assembly to the global assembly cache on the client computer.
Add a reference to the assembly in the COM client application.
Answer: B
Explanation: The Assembly Registration tool reads the metadata within an assembly and
adds the necessary entries to the registry, which allows COM clients to create .NET
Framework classes transparently. Once a class is registered, any COM client can use it as
though the class were a COM class.
Reference:
.NET Framework Tools, Assembly Registration Tool (Regasm.exe)
.NET Framework Tools, Strong Name Tool (Sn.exe)
.NET Framework Tools, Type Library Importer (Tlbimp.exe)
Incorrect Answers
A: The Strong Name tool helps sign assemblies with strong names.
C: The Type Library Importer, tlbimp.exe, converts the type definitions found within a
COM type library into equivalent definitions in a common language runtime assembly. It
would not be useful in this scenario however.
D: This would not allow the COM application to use the class.
# QUES:
You development team used Visual Studio .NET to create an accounting
application, which contains a class named Abc Accounts. This class instantiates
several classes from a COM component that was created by using Visual Basic 6.0.
Each COM component class includes a custom method named ShutDownObject
that must be called before terminating references to the class.
Software testers report that the COM component appears to remain in memory
after the application terminates. You must ensure that the ShutDownObject method
of each COM component class is called before Abc Accounts is terminated.
What should you do?
A. Add code to the Terminate event of Abc Accounts to call the ShutDownObject
method of each COM component class.
B. Find each location in your code where a reference to Abc Accounts is set to null
or goes out of scope.
Add code after each instance to manually invoke the Visual Studio .NET garbage
collector.
C. Add a destructor to Abc Accounts.
Add code to the destructor to call the ShutDownObject method of each COM component
class.
D. Add the procedure private void Finally() to Abc Accounts.
Add code to the procedure to call the ShutDownObject method of each COM component
class.
Answer: C
Explanation: Be creating a destructor for Abc Accounts class we can ensure
that appropriate actions are performed before Abc Accounts is terminated.
Reference: C# Language Specification, Destructors
# QUES:
Your development team is creating a new Windows-based application for the
Abc company. The application consists of a user interface and several XML
Web services. You develop all XML Web services and perform unit testing. Now
you are ready to write the user interface code.
Because some of your servers are being upgraded, the XML Web service that
provides mortgage rates is currently offline. However, you have access to its
description file.
You must begin writing code against this XML Web service immediately.
What should you do?
A. Generate the proxy class for the XML Web service by using Disco.exe.
B. Generate the proxy class for XML Web service by using Wsdl.exe.
C. Obtain a copy of the XML Web service assembly and register it on your local
development computer.
D. Add the description file for the XML Web service to your Visual Studio .NET project.
Answer: B
Explanation:
Ordinarily to access an XML Web service from a client application, you first add a Web
reference, which is a reference to an XML Web service. When you create a Web
reference, Visual Studio creates an XML Web service proxy class automatically and adds
it to your project.
However, you can manually generate a proxy class using the XML Web services
Description Language Tool, Wsdl.exe, used by Visual Studio to create a proxy class
when adding a Web reference. This is necessary when you are unable to access the XML
Web service from the machine on which Visual Studio is installed, such as when the
XML Web service is located on a network that will not be accessible to the client until
run time. You then manually add the file that the tool generated to your application
project.
Reference:
Visual Basic and Visual C# Concepts, Locating XML Web Services
Visual Basic and Visual C# Concepts, Generating an XML Web Service Proxy
# QUES:
You use Visual Studio .NET to create an application. Your application contains two
classes, Region and City, which are defined in the following code segment. (Line
numbers are included for reference only)
01 public class Region {
02 public virtual void Calculate Xyz Tax() {
03 // Code to calculate tax goes here.
04 }
05 }
06 public class City:Region {
07 public override void Calculate Xyz Tax() {
08 // Insert new code.
09 }
10 }
You need to add code to the Calculate Xyz Tax method of the City class to call the
Calculate Xyz Tax method of the Region class.
Which code segment should you add on line 08?
A. Calculate Xyz Tax();
B. this.Calculate Xyz Tax();
C. base.Calculate Xyz Tax();
D. Region r = new Region();r.Calculate Xyz Tax();
Answer: C
# QUES:
You use Visual Studio .NET to develop applications for your human resources
department at Abc . You create the following interfaces:
Abc . You create the following interfaces:
public interface IEmployee {
double Salary();
}
public interface IExecutive: IEmployee {
double AnnualBonus();
}
The IEmployee interface represents a generic Employee concept. All actual
employees in your company should be represented by interfaces that are derived
from IEmployee.
Now you need to create a class named Manager to represent executives in your
company. You want to create this class by using the minimum amount of code.
Which code segment or segments should you include in Manager? (Choose all that
apply)
A. public class Manager:IExecutive
B. public class Manager:IEmployee, IExecutive
C. public class Manager:IEmployee
D. public class Manager:IExecutive, IEmployee
E. public double Salary()
F. public double AnnualBonus()
Answer: A, E, F
A: A class can implement an Interface. The Manager class should implement the
IExecutive interface.
E, F: The properties that are defined in the Interface must be implemented in a Class.
Incorrect Answers
B: The class should not implement both Interfaces, just the IExecutive interface.
C, D: A class cannot inherit from an Interface.
# QUES:
You plan to use Visual Studio. NET to create a class named Xyz BusinessRules,
which will be used by all applications in your company. Xyz BusinessRules defines
business rules and performs calculations based on those rules. Other developers in
your company must not be able to override the functions and subroutines defined in
Xyz BusinessRules with their own definitions.
Which two actions should you take to create BusinessRules? (Each correct answer
presents part of the solution. Choose two)
A. Create a Windows control library project.
B. Create a class library project.
C. Create a Windows Service project.
D. Use the following code segment to define BusinessRules:
protected class Xyz BusinessRules
E. Use the following code segment to define BusinessRules:
public new class Xyz BusinessRules
F. Use the following code segment to define BusinessRules:
public sealed class Xyz BusinessRules
G. Use the following code segment to define BusinessRules:
public abstract class Xyz BusinessRules
Answer: B, F
Explanation:
B: You can use the Class Library template to quickly create reusable classes and
components that can be shared with other projects.
F: A sealed class cannot be inherited. It is an error to use a sealed class as a base class.
Use the sealed modifier in a class declaration to prevent accidental inheritance of the
class.
Reference:
Visual Basic and Visual C# Concepts, Class Library Template
C# Programmer's Reference, sealed
70-306/70-316 Training kit, Creating Classes That Cannot Be Inherited, Page 182
Incorrect Answers
A: The Windows Control Library project template is used to create custom controls to
use on Windows Forms.
C: When you create a service, you can use a Visual Studio .NET project template called
Windows Service. However, we want to implement Business rules, not network services.
D: A protected class will hide properties from external classes and thus keep this
functionality encapsulated within the class. However, the class could still be overridden.
E: Incorrect use of keyword new." Option E produces compile time error, so you can't
even create class with that syntax, so it surely dont let the developers to inherit from (nor
to override it's members).
G: The abstract modifier is used to indicate that a class is incomplete and that it is
intended to be used only as a base class.
# QUES:
You use Visual Studio .NET to create a Windows-based application that will track
Abc sales. The application's main object is named Abc . The Abc class is
created by the following definition:
public class Abc {
}
You write code that sets properties for the Abc class. This code must be
executed as soon as an instance of the Abc class is created.
Now you need to create a procedure in which you can place your code. Which code
segment should you use?
A. public Abc ()
B. public void Abc ()
C. public bool Abc ()
D. public New()
E. public Abc New()
F. public Abc Abc ()
Answer: A
Explanation: We must create a constructor for the class. We wrote a method whose
name is the same as the name of the class, and we specify not return type, not even
void.
Reference: Visual C# Step by step, page 144
Incorrect Answers
B, C: We cannot specify any return type, not even void, when we define a constructor for
a class.
D: The constructor must have the name of the class.
Incorrect syntax. This is not the way to create a constructor.
# QUES:
Another developer creates data files by using a computer that runs a version of
Microsoft Windows XP Professional distributed in France. These files contain
financial transaction information, including dates, times, and monetary values. The
data is stored in a culture-specific format.
You develop an application Abc Interactive, which uses these data files. You
must ensure that Abc Interactive correctly interprets all the data, regardless of
the Culture setting of the client operating system.
Which code segment should you add to your application?
A. using System.Threading;
using System.Data;
Thread.CurrentThread.CurrentCulture =
new CultureInfo("fr-FR");
B. using System.Threading;
using System.Data;
Thread.CurrentThread.CurrentCulture =
new TextInfo("fr-FR");
C. using System.Threading;
using System.Globalization;
Thread.CurrentThread.CurrentCulture=
new CultureInfo("fr-FR");
D. using System.Threading;
using System.Globalization;
Thread.CurrentThread.CurrentCulture=
new TextInfo("fr-FR");
Answer: C
Explanation: The CultureInfo represents information about a specific culture
including the names of the culture, the writing system, and the calendar used, as
well as access to culture-specific objects that provide methods for common
operations, such as formatting dates and sorting strings.
Reference: 70-306/70-316 Training kit, Getting and Setting the Current Culture, Pages
403-404
.NET Framework Class Library, CultureInfo Class [C#]
Incorrect Answers
A: We must use the System.Globalization namespace, not the System.Data namespace
B, D: The TextInfo property provides culture-specific casing information for strings.
# QUES:
You use Visual Studio .NET to create an application named Abc Client.
Another developer in your company creates a component named
Abc Component. Your application uses namespaces exposed by
Abc Component.
You must deploy both Abc Client and Abc Component to several
computers in your company's accounting department. You must also ensure that
Abc Component can be used by future client applications.
What are three possible ways to achieve your goal? (Each correct answer presents a
complete solution. Choose three)
A. Deploy Abc Client and Abc Component to a single folder on each client
computer.
Each time a new client application is developed, place the new application in its own
folder and copy Abc Component to the new folder.
B. Deploy Abc Client and Abc Component to a single folder on each client
computer.
Each time a new client application is developed, place the new application in its own
folder.
Edit Abc Client.exe.config and add a privatePath tag that points to the folder where
Abc Component is located.
C. Deploy Abc Client and Abc Component to separate folders on each client
computer.
In each client application that will use Abc Component, add the following code
segment: using Abc Component;
D. Deploy Abc Client and Abc Component to separate folders on each client
computer.
Each time a new client application is developed, select Add Reference from the Tools
menu and add a reference to Abc Component.
E. Deploy Abc Client and Jack CBill Component to separate folders on each client
computer.
Register Abc Component on each client computer by using the RegSvr32 utility.
F. Deploy Abc Client and Abc Component to separate folders on each client
computer.
Add Abc Component to the global assembly cache.
Answer: A, B, F
Explanation:
A: XCOPY deployment of the Abc Component, we simply copy the component to
the deployment folder of every application that requires the use of the components,
enables the deployed application to use the component.
B: This would give the future client applications access to Abc Component.
F: If you intend to share an assembly among several applications, you can install it into
the global assembly cache.
Reference:
70-306/70-316 Training kit, Accessing .NET and COM Type Libraries, Pages 386-387
.NET Framework Developer's Guide, Working with Assemblies and the Global
Assembly Cache
C# Programmer's Reference, using Directive
Incorrect Answers
C: The using keyword has two major uses:
using Directive Creates an alias for a namespace.
using Statement Defines a scope at the end of which an object will be disposed.
However, this would not make the component accessible.
D: Adding references does not provide access to library in runtime (FileNotFound
exception).
E: RegSrv32 was used in before the introduction of Visual Studio .NET to register .dll
file. It is no longer required.
# QUES:
You are preparing a localized version of a Windows Form named Abc Local.
Users of Abc Local speak a language that prints text from right to left. User
interface elements on the form need to conform to this alignment.
You must ensure that all user interface elements are properly formatted when the
localized Windows Form runs. You must also ensure that Abc Local is easy to
update and maintain.
What should you do?
A. Set the RightToLeft property of each control on the form to Yes.
B. Set the RightToLeft property of the form to Yes.
C. Set the Language property of the form to the appropriate language.
D. Set the Localizable property of the form to True.
Answer: B
Explanation: The RightToLeft property is used for international applications where
the language is written from right to left
Reference:
Visual Basic and Visual C# Concepts, Displaying Right-to-Left Text in Windows Forms
for Globalization
Incorrect Answers
A: The RightToLeft property can be set either to controls or to the form. The best
solution is to set the property only for the form.
C: The Language property is not used to format text.
D: The Localizable property is not used to format text.
# QUES:
You work as a software developer at Abc .com. You create a form in your
Windows-based application. The form contains a command button named
check Abc Button. When check Abc Button is clicked, the application must
call a procedure named Get Abc .
Which two actions should you take? (Each correct answer presents part of the
solution. Choose two)
A. Add arguments to the Get Abc declaration to accept System.Object and
System.EventArgs.
B. Add arguments to the check Abc Button_Click declaration to accept
System.Object and System.EventArgs.
C. Add code to Get Abc to call check Abc Button_Click.
D. Add the following code segment at the end of the Get Abc declaration:
Handles check Abc Button.Click
E. Add the following code segment at the end of the check Abc Button_Click
procedure:
Handles Get Abc
Answer: B, D
# QUES:
You develop an inventory management application for Abc . The application
uses a SqlDataReader object to retrieve a product code list from a database. The list
is displayed in a drop-down list box on a Windows Form.
The Form_Load procedure contains the following code. (Line numbers are included
for reference only)
01 public void ReadMyData (String ConnectionString)
02 {
03 String query =
04 "SELECT CatID, CatName FROM Abc Categories";
05 SqlConnection cnn = new
06 SqlConnection (ConnectionString);
07 SqlCommand cmd = new SqlCommand(query, cnn);
08 SqlDataReader reader;
09 cnn.Open();
10 // Insert new code.
11 cnn.Close();
12 }
To enable your application to access data from the SqlDataReader object, you need to insert
additional code on line 10. Your insertion must minimize the use of database server resources without
adversely affecting application performance.
Which code segment should you use?
A. reader = cmd.ExecuteReader();
while (reader.Read()) {
ListBox1.Items.Add(reader.GetString(1));
reader.NextResult();
}
B. reader = cmd.ExecuteReader();
while (reader.Read()) {
ListBox1.Items.Add(reader.GetString(1));
}
C. reader = cmd.ExecuteReader();
while (reader.Read()) {
ListBox1.Items.Add(reader.GetString(1));
}
reader.Close();
D. reader = cmd.ExecuteReader();
while (reader.Read()) {
ListBox1.Items.Add(reader.GetString(1));
reader.NextResult();
}
reader.Close();
# QUES:
You use Visual Studio .NET to create a Windows-based application for Abc
Inc. The application enables users to update customer information that is stored in a
database.
Your application contains several text boxes. All TextBox controls are validated as
soon as focus is transferred to another control. However, your validation code does
not function as expected. To debug the application, you place the following line of
code in the Enter event handler for the first text box:
You repeat the process for the Leave, Validated, Validating, and TextChanged
events. In each event, the text is displayed in the output window contains the name
of the event being handled.
You run the application and enter a value in the first TextBox control. Then you
change focus to another control to force the validation routines to run.
Which code segment will be displayed in the Visual Studio .NET output windows?
A. Enter Validating TextChanged Leave Validated
B. Enter TextChanged Leave Validating Validated
C. Enter Validating Validated TextChanged Leave
D. Enter TextChanged Validating Validated Leave
E. Enter Validating TextChanged Validated Leave
Answer: B
# QUES:
You create the user interface for a Windows-based application. The main form in
your application includes an Exit menu item named exitItem and an Exit button
named exitCommand.
You want the same code to run whether the user clicks the menu item or the button.
You want to accomplish this goal by writing the shortest possible code segment.
Which code segment should you use?
A. private void HandleExit( object sender, System.EventArgs e) { //
Insert application exit code. }
private void MainForm_Load( object sender, System.EventArgs e) {
this.exitCommand.Click += new System.EventHandler(HandleExit);
this.exitItem.Click += new System.EventHandler(HandleExit); }
B. private void HandleExit( object sender, System.EventArgs e) { //
Insert application exit code. }
private void MainForm_Load( object sender, System.EventArgs e) {
new System.EventHandler(HandleExit);
new System.EventHandler(HandleExit); }
C. private void HandleExit() { // Insert application exit code. }
private void MainForm_Load( object sender, System.EventArgs e) {
this.exitCommand.Click += new System.EventHandler(HandleExit);
this.exitItem.Click += new System.EventHandler(HandleExit); }
D. private void exitCommand_Click( object sender, System.EventArgs e)
{ // Insert application exit code. } private void exitItem_Click(
object sender, System.EventArgs e) { // Insert application exit
code. }
Answer: A
# QUES:
You use Visual Studio .NET to create a component named Reabct. This component
includes a method named AcceptCKReabct, which tries to process new user
reabcts for services. AcceptCKReabct calls a private function named Validate.
You must ensure that any exceptions encountered by Validate are bubbled up to the
parent form of Reabct. The parent form will then be responsible for handling the
exceptions. You want to accomplish this goal by writing the minimum amount of
code.
What should you do?
A. Use the following code segment in AcceptCKReabct:
this.Validate();
B. Use the following code segment in AcceptCKReabct:
try {
this.Validate();
}
catch(Exception ex) {
throw ex;
}
C. Use the following code segment in AcceptCKReabct:
try {
this.Validate();
}
catch(Exception ex) {
throw new Exception("Exception in AcceptCKReabct", ex);
}
D. Create a custom Exception class named ReabctException by using the following code segment:
public class ReabctException:ApplicationException {
public ReabctException():base() {
}
public ReabctException
(string message):base(message) {
}
public ReabctException(string message,
Exception inner):base(message, inner) {
}
}
In addition, use the following code segment in AcceptCKReabct:
try {
this.Validate();
}
catch(Exception ex) {
throw new ReabctException("Exception in AcceptCKReabct",
ex);
}
Answer: A
Explanation: The unhandled exception automatically will be thrown to the client
application. This solution meets the requirement that the least amount of code
should be used.
Not B: Options A and B produce the same result. Option A is better solution because of
minimized coding. Catching and just throwing an exception in the catch block, without
any additional processing is meaningless.
# QUES:
You use Visual Studio .NET to create a Windows-based application. The application
includes a form named Abc . You implement print functionality in Abc by
using the native .NET System Class Libraries.
Abc will print a packing list on tractor-fed preprinted forms. The packing list
always consists of two pages. The bottom margin of page 2 is different from the
bottom margin of page 1.
You must ensure that each page is printed within the appropriate margins.
What should you do?
A. When printing page 2, set the bottom margin by using the PrintPageEventArgs object.
B. When printing page 2, set the bottom margin by using the
QueryPageSettingEventArgs object.
C. Before printing, set the bottom margin of page 2 by using the PrintSetupDialog object.
D. Before printing, set the bottom margin of page 2 by using the PrinterSettings object.
Answer: B
Explanation:
It is possible to print each page of a document using different page settings. You set page
settings by modifying individual properties of the
QueryPageSettingsEventArgs.PageSettings property. Changes made to the PageSettings
affect only the current page, not the document's default page settings.
The PageSettings Class specifies settings that apply to a single, printed page. It is used to
specify settings that modify the way a page will be printed.
Reference:
.NET Framework Class Library, PrintDocument.PrintPage Event
.NET Framework Class Library, PrintDocument.QueryPageSettings Event [C#]
.NET Framework Class Library, PrintDocument.PrintPage Event [C#]
Incorrect Answers
A: The pageSettings property of PrintPageEventArgs is read only.
C: PrintSetupDialog object cannot be used to specify specific print settings of page 2.
D: The PrinterSettings object sets general Printer properties. It does no apply here.
# QUES:
You use Visual Studio .NET to create a Windows-based application. The application
includes a form named Abc Procedures (CKP). CKP allows users to enter very
lengthy text into a database. When users click the Print button located on CKP, this
text must be printed by the default printer. You implement the printing
functionality by using the native .NET System Class Libraries with all default
settings.
Users report that only the first page of the text is being printed.
How should you correct this problem?
A. In the BeginPrint event, set the HasMorePages property of the PrintEventArgs object
to True.
B. In the EndPrint event, set the HasMorePages property of the PrintEventArgs object to
True.
C. In the PrintPage event, set the HasMorePages property of the PrintPageEventArgs
object to True.
D. In the QueryPageSettings event, set the HasMorePages property of the
QueryPageSettingEventArgs object to True.
Answer: C
Explanation: PrintDocument.PrintPage Event occurs when the output to print for
the current page is needed. This event has the HasMorePages property which gets
or sets a value indicating whether an additional page should be printed.
Reference:
.NET Framework Class Library, PrintDocument Class [Visual Basic]
.NET Framework Class Library, PrintDocument.PrintPage Event [Visual Basic]
# QUES:
You develop an application that includes a Contact Class. The contact class is
defined by the following code:
public class Contact{
private string name;
public event EventHandler ContactSaved;
public string Name {
get {return name;}
set {name = value;}
}
public void Save () {
// Insert Save code.
// Now raise the event.
OnSave();
}
public virtual void OnSave() {
// Raise the event:
if (ContactSaved != null) {
ContactSaved(this, null);
}
}
}
You create a form named Abc Form. This form must include code to handle the
ContactSaved event raised by the Contact object. The Contact object will be
initialized by a procedure named CreateContact.
Which code segment should you use?
A. private void HandleContactSaved() {
// Insert event handling code.
}
private void CreateContact() {
Contact oContact = new Contact();
oContact.ContactSaved +=
new EventHandler(HandleContactSaved);
oContact.Name = " Abc ";
oContact.Save();
}
B. private void HandleContactSaved(
object sender, EventArgs e) {
// Insert event handling code.
}
private void CreateContact() {
Contact oContact = new Contact();
oContact.Name = " Abc ";
oContact.Save();
}
C. private void HandleContactSaved(
object sender, EventArgs e) {
// Insert event handling code.
}
private void CreateContact() {
Contact oContact = new Contact();
oContact.ContactSaved +=
new EventHandler (HandleContactSaved);
oContact.Name = " Abc ";
oContact.Save();
}
D. private void HandleContactSaved(Object sender, EventArgs e) {
// Insert event-handling code.
}
private void CreateContact() {
Contact oContact = new Contact();
new EventHandler(HandleContactSaved);
oContact.Name = " Abc ";
oContact.Save();
}
Answer: C
Explanation: The delegate is correctly declared with appropriate parameters:
private void HandleContactSaved(object sender, EventArgs e)
The association between the delegate and the event is correctly created with the +=
operator:
oContact.ContactSaved += new EventHandler
(HandleContactSaved)
Note:
An event handler is a method that is called through a delegate when an event is raised,
and you must create associations between events and event handlers to achieve your
desired results. In C# the += operator is used to associate a delegate with an event..
Reference: 70-306/70-316 Training kit, Implementing Event Handlers, Pages 143-144
Incorrect Answers
A: The declaration of the delegate do not contain any parameters.
private void HandleContactSaved()
B: There is no association made between the delegate and the event.
D: The association between the delegate an the event is incorrect. The += operator must
be used:
new EventHandler(HandleContactSaved)
# QUES:
You are a developer for a Abc Inc that provides free software over the
Internet. You are developing en e-mail application that users all over the world can
download.
The application displays text strings in the user interface. At run time, these text
strings must appear in the language that is appropriate to the locale setting of the
computer running the application.
You have resources to develop versions of the application for only four different
cultures. You must ensure that your application will also be usable by people of
other cultures.
How should you prepare the application for deployment?
A. Package a different assembly for each culture.
B. Package a different executable file for each culture.
C. Package a main assembly for source code and the default culture.
Package satellite assemblies for the other cultures.
D. Package a main assembly for source code.
Package satellite assemblies for each culture.
Answer: C
Explanation: When you build a project, the resource files are compiled and then
embedded in satellite assemblies, or assemblies which contain only the localized
resources. The fallback resources are built into the main assembly, which also
contains the application code.
Reference:
Visual Basic and Visual C# Concepts, What's New in International Applications
Visual Basic and Visual C# Concepts, Introduction to International Applications in
Visual Basic and Visual C#
Incorrect Answers
A: A main assembly is needed.
B: Assemblies not executables are used.
D: The main assembly contains the fallback resources (including default culture).
# QUES:
You use the .NET Framework to develop a new Windows-based application. The
application includes a COM component that you created.
Abc .com company policy requires you to sign the Abc Op assembly with a
strong name. However, issues of company security require that you delay signing
the assembly for one month. You need to begin using the application immediately on
a pilot basis. You must achieve your goal with the least possible effort.
What should you do?
A. Create a reference to the COM component through the Visual Studio .NET IDE.
B. Create the Abc Op assembly by using the Type Library Importer (Tlbimp.exe).
C. Create the Abc Op assembly by using the TypeLibConverter class in the
System.Runtime. Abc OpServices namespace.
D. Create a custom wrapper by creating a duplicate definition or interface of the class in
managed source code.
Answer: B
Explanation:
The easiest way to do this is by delayed signing with Tlbimp.exe, option B.
# QUES:
You use Visual Studio .NET to create several Windows-based applications. All use a
common class library assembly named Abc Customers. You deploy the
application to client computers on your company intranet.
Later, you modify Abc Customers.Any application that uses version 1.0.0.0
must now user version 2.0.0.0.
What should you do?
A. Modify the machine configuration file on your client computers.
B. Modify the application configuration file for Customers.
C. Modify the Publisher Policy file containing a reference to Customers.
D. Modify the reference patch for Customers.
Answer: C
Explanation: When an assembly vendor releases a new version of an assembly, the
vendor can include a publisher policy so applications that use the old version now
use the new version.
Reference:
.NET Framework General Reference,
# QUES:
Your company uses Visual Studio .NET to create a Windows-based application for
Abc . The application is named CustomerTracker, and it calls an assembly
named Schedule.
Six months pass. The hospital asks your company to develop a new Windows-based
application. The new application will be named EmployeeTracker, and it will also
call Schedule. Because you anticipate future revisions to this assembly, you want
only one copy of Schedule to serve both applications.
Before you can use Schedule in EmployeeTracker, you need to complete some
preliminary tasks.
Which three actions should you take? (Each correct answer presents part of the
solution. Choose three)
A. Create a strong name for Schedule.
B. Use side-by-se execution to run Schedule.
C. Install Schedule in the global assembly cache.
D. Move Schedule to the Windows\System32 folder.
E. Create a reference in EmployeeTracker to Schedule.
F. Create a reference in EmployeeTracker to CustomerTracker.
Answer: A, C, E
Explanation:
A: An assembly must have a strong name to be installed in the global assembly cache.
C: You intend to share an assembly among several applications, you can install it into the
global assembly cache.
E: We must create a reference from the application (EmployeeTracker) to the assembly
(Schedule).
Reference:
.NET Framework Developer's Guide, Working with Assemblies and the Global
Assembly Cache
.NET Framework Developer's Guide, Side-by-Side Execution
Incorrect Answers
B: Side-by-side execution is the ability to run multiple versions of the same assembly
simultaneously. It is not required in this scenario.
D: The assembly should be moved to the global assembly cache, not to the
Windows\System32 folder.
F: The application should reference the assembly, not the first application.
# QUES:
You use Visual Studio .NET to create an assembly that will be consumed by other
Visual Studio .NET applications. No Permissions should be granted to this assembly
unless the assembly makes a minimum permission reabct for them.
Which code segment should you use?
A.
PermissionSet(SecurityAction.PermitOnly, _
Unrestricted := True)>
B.
PermissionSet(SecurityAction.PermitOnly, _
Unrestricted := False)>
C.
PermissionSet(SecurityAction.ReabctOptional,_
Unrestricted := True)>
D.
PermissionSet(SecurityAction.ReabctOptional, _
Unrestricted := False)>
Answer: D
Explanation: The ReabctOptional SecurityAction reabcts for additional
permissions that are optional (not required to run). This action can only be used
within the scope of the assembly. The code needs only the minimum set of
permissions and no others. It should not be granted any optional permissions that it
has not specifically reabcted. We must therefore use Unrestricted := False.
Reference:
.NET Framework Developer's Guide, Reabcting Optional Permissions
Incorrect Answers:
A, B: The PermitOnly
SecurityAction does not support Assembly as a target, it only supports Class or Method
as targets.
C: The assembly must only be granted minimal permissions. It should not be granted any
optional permissions that it has not specifically reabcted.
# QUES:
You develop a Windows-based application to manage inventory for Abc inc.
The application calls a Microsoft SQL Server stored procedure named
sp_UpdatePrices.
sp_UpdateCKPrices performs a SQL UPDATE statement that increases prices for
selected items in an inventory table. It returns an output parameter named
@totalprice and a result set that contains all of the records that were updated.
@totalprice contains the sum of the prices of all items that were updated.
You implement a SqlCommand object that executes sp_UpdateCKPrices and
returns the results to a SqlDataReader object. The SqlDataReader object gives you
access to the data in the result set. Which is displayed in a list box on your Windows
Form.
The value of @totalprice must also be displayed in a text box on your Windows
Form. You need to write code that will retrieve this value.
Which code segment should you use?
A.While (reader.Read() {
TextBox1.Text= com.parameters['@totalprice"].value.ToString();
} reader.close();
B.do { TextBox1.Text = com.parameters ["@totalprice"].Value.ToString();
} While (reader.Read()); reader.close
C.TextBox1.Text=
com.parameters["@totalprice"].value.ToString(); reader.close(); D.reader.close();
TextBox1.Text= com.parameters["@totalprice"].value.ToString(); A.cmd.executeNonQuery();
Answer:D
Explanation:The correct answer is D,the output parameter is not available until after the reader is closed.
# QUES:
You use Visual Studio .NET to create an application that uses an assembly. The
assembly will reside on the client computer when the application is installed. You
must ensure that any future applications installed on the same computer can access
the assembly.
Which two actions should you take? (Each correct answer presents part of the
solution. Choose two)
A. Use XCOPY to install the assembly in the global assembly cache.
B. Use XCOPY to install the assembly in the Windows\Assembly folder.
C. Create a strong name for the assembly.
D. Recompile the assembly by using the Native Image Generator (Ngen.exe).
E. Modify the application configuration file to include the assembly.
F. Use a deployment project to install the assembly in the global assembly cache.
G. Use a deployment project to install the assembly in the Windows\System32 folder.
Answer: C, F
Explanation:
The global assembly cache stores assemblies specifically designated to be shared by
several applications on the computer.
C: An assembly must have a strong name to be installed in the global assembly cache.
F: There are two ways to install an assembly into the global assembly cache:
1. Using Microsoft Windows Installer 2.0. This could be achieved by a deployment
project.
2. Using the Global Assembly Cache tool (Gacutil.exe). This is not an option here.
Reference:
.NET Framework Developer's Guide, Working with Assemblies and the Global
Assembly Cache
.NET Framework Developer's Guide, Installing an Assembly into the Global Assembly
Cache
# QUES:
You use Visual Studio .NET to create a control that will be used on several forms in
your application. It is a custom label control that retrieves and displays your
company's current stock price.
The control will be displayed on many forms that have different backgrounds. You
want the control to show as much of the underlying form as possible. You want to
ensure that only the stock price is visible. The rectangular control itself should not
be visible.
You need to add code to the Load event of the control to fulfill these requirements.
Which two code segments should you use? (Each correct answer presents part of the
solution. Choose two)
A. ContextMenu1.MenuItems.Clear();
B. ContextMenu1.MenuItems.Add("&Display Help");
C. ContextMenu1.MenuItems.Add(helpCKOption.CloneMenu();
D. ContextMenu1.MenuItems[0].Click += new
System.EventHandler(helpCKOption_Click)
E. this.SetStyle(ControlStyles.SupportsTransparentBackColor,true )
Answer: A, E
Explanation:
To give your control a transparent backcolor:
1. Call the SetStyle method of your form in the constructor.
this.setStyle(ControlStyles.SupportsTransparentBackColor,
This will enable your control to support a transparent backcolor.
2. Beneath the line of code you added in step 1, add the following line. This will set your
control's BackColor to Transparent. :
this.Backcolor=color.Transparent; Reference: Visual Basic and Visual C# Concepts, Giving Your
Control a
Transparent
Background
# QUES.
You are developing a Windows-based application that logs hours worked by
Abc employees. Your design goals require you to maximize application
performance and minimize impact on server resources.
You need to implement a SqlCommand object that will send a SQL INSERT action
query to a database each time a user makes a new entry.
To create a function named LineItemInsert, you write the following code. (Line
numbers are included for reference only)
01 public int LineItemInsert(int empID, int projectID,
02 decimal hrs, SqlConnection cnn)
03 {
04 string SQL;
05 int Ret;
06
07 SQL = String.Format(
08 "INSERT INTO TimeEntries (EmpID, ProjectID, Hours) "
09 + 10 "VALUES ({0}, {1}, {2})",
11 empID, project ID, hrs);
12 SqlCommand cmd = new SqlCommand(SQL, cnn);
13
14 // Insert new code.
15 }
You code must execute the SQL INSERT action query and verify the number of database records that
are affected by the query.
Which code segment should you add on line 14?
A. cnn.Open(); Ret = cmd.ExecuteNonQuery(); cnn.Close(); return Ret;
B. cnn.Open(); Ret = cmd.ExecuteScalar(); cnn.Close(); return Ret;
C. SqlDataReader reader; cnn.Open(); reader = cmd.ExecuteReader();
cnn.Close() return reader.RecordsAffected;
D. SqlDataReader reader; cnn.Open(); reader = cmd.ExecuteReader();
cnn.Close(); return reader.GetValue();
Answer: A
# QUES:
You develop a Windows-based application. You plan to use ADO.NET to call a
Microsoft SQL Server stored procedure named Abc EmployeeData. This
procedure accepts a parameter for querying the database by an employee's family
name.
You need to add code to your application to set up the parameter for use with the
stored procedure.
Which three lines of code should you add? (Each correct answer presents part of the
solution. Choose three)
A. SqlParameter prm = new SqlParameter();
B. SqlParameter prm = new SqlParameter( "@FamilyName",
SqlDbType.VarChar);
C. prm.Direction = ParameterDirection.Input;
D. prm.Direction = ParameterDirection.InputOutput;
E. cmd.Parameters.Add(prm);
F. cmd.Parameters[0] = prm;
Answer: B, C, E
# QUES:
You develop a Windows-based application that accesses a Microsoft SQL Server
database. The application includes a form named CustomerForm, which contains a
Button control named SortButton. The database includes a table named Customers.
Data from Customers will be displayed on CustomerForm by means of a DataGrid
control named DataGrid1. The following code segment is used to fill DataGrid1:
private void FillDataGrid() {
SqlConnection cnn = new SqlConnection(
"server=localhost;uid=sa;pwd=;database= Abc Sales");
SqlDataAdapter da = new SqlDataAdapter(
"SELECT CKCustomerID, ContactName, CITY " +
"FROM Customers", cnn);
DataSet ds = new DataSet();
da.MissingSchemaAction = MissingSchemaAction.AddWithKey;
da.Fill(ds, "Customers");
DataView dv = new DataView(ds.Tables["Customers"]);
dv.Sort = "City ASC, ContactName ASC";
dv.ApplyDefaultSort = true;
dataGrid1.DataSource = dv;
}
The primary key for Customers is the CKCustomerID column. You must ensure
that the data will be displayed in ascending orderby primary key when the user
selects SortButton.
What should you do?
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. Include an ORDER BY clause in the SELECT statement when you create the Data
Adapter object.
D. Set the RowFilter property of the DataView object to CustomerID.
Answer: A
Explanation: The data view definition includes the follow command:
dv.sort = "city ASC,contactName ASC"; This enforces sorting on the City and the ContactName
columns. It
overrides the default
sort order. We must set the Sort property to an empty string. This would enable the
default sort order.
Reference: Visual Basic and Visual C# Concepts, Filtering and Sorting Data Using Data
Views
Incorrect Answers
B: By default a view is sorted on the Primary Key in ascending order. We would to set
the ApplyDefaultSort to true, not to false.
C: A ORDER BY clause cannot be used in a view.
D: The RowFilter property does not affect the sort configuration.
# QUES:
You use Visual Studio .NET to develop a Windows-based application called
Abc App. Your application will display customer orderinformation from a
Microsoft SQL Server database. The orders will be displayed on a Windows Form
in a data grid named DataGrid1. DataGrid1 is bound to a DataView object.
The Windows Form includes a button control named displayBackOrder. When
users click this button, DataGrid1 must display only customer orders whose
BackOrder value is set to True.
How should you implement this functionality?
A. Set the RowFilter property of the DataView object to "BackOrder = True".
B. Set the RowStateFilter property of the DataView object to "BackOrder = True".
C. Set the Sort property of the DataView object to "BackOrder = True".
D. Set the ApplyDefaultSort property of the DataView object to True.
Answer: A
Explanation: Using the RowFilter property of a data view, you can filter records in
a data table to make available only records you want to work with.
Reference:
Visual Basic and Visual C# Concepts, Introduction to Filtering and Sorting in Datasets
Visual Basic and Visual C# Concepts, Filtering and Sorting Data Using Data Views
Incorrect Answers
B: To filter based on a version or state of a record, set the RowStateFilter property. It
does not apply here.
C, D: We want to filter, not sort the data view.
# QUES:
You use Visual Studio .NET to develop a Windows-based application that interacts
with a Microsoft SQL Server database. Your application contains a form named
CustomerForm, which includes the following design-time components:
1. SqlConnection object named Abc Connection.
2. SqlDataAdapter object named Abc DataAdapter.
3. DataSet object named Abc DataSet, based on a database table named
Customers.
At run time you add a TextBox control named textCompanyName to
CustomerForm. You execute the Fill method of Abc DataAdapter to populate
Customers. Now you want to use data binding to display the CompanyName field
exposed by Abc DataSet in textCompanyName.
Which code segment should you use?
A. textCompanyName.DataBindings.Add("Text", Abc DataSet,
"CompanyName");
B. textCompanyName.DataBindings.Add("Text", Abc DataSet,
"Customers.CompanyName");
C. textCompanyName.DataBindings.Add("Text", Abc DataAdapter,
"CompanyName");
D. textCompanyName.DataBindings.Add("Text", Abc DataAdapter,
"Customers.CompanyName");
Answer: B
No comments:
Post a Comment