Monday, December 31, 2007

Certification Id : 070-316
Developing Windows-based Applications.# 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 ifValid Abc Password returns a value of False. You will add the required code online 6.A. e.Cancel = true;B. sender name;C. password.AcceptsTab = false ;D. password.CausesValidation = false ;Answer: AExplanation: If the input in the control does not fall within required parameters, theCancel property within your event handler can be used to cancel the Validatingevent and return the focus to the control.Reference: 70-306/70-316 Training kit, The Validating and Validated Events, Page 89Incorrect AnswersB: Setting an object to an unknown variable is rubbish.C: The AccptsTab property gets or sets a value indicating whether pressing the TAB keyin a multiline text box control types a TAB character in the control instead of moving thefocus to the next control in the tab order.D: The CausesValidation property gets or sets a value indicating whether validation isperformed when the Button control is clicked.
# Ques:You use Visual Studio .NET to create a Windows-based application. The applicationincludes a form named Abc Form.Abc Form contains 15 controls that enable users to set basic configurationoptions 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 isresized. 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 willnot be displayed correctly. You must ensure that users cannot resizeConfigurationForm to be smaller than 500 x 600 pixels.Which two actions should you take to configure Abc Form? (Each correctanswer 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, HExplanation:A: The Form.MinimumSize Property gets or sets the minimum size the form can beresized 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 beset to "650, 700".Reference:.NET Framework Class Library, Form.MinimumSize Property [C#].NET Framework Class Library, Form.Size Property [C#]Incorrect AnswersB: 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 tomaintain database records in a table named Abc .You need to add several pairs of controls to Abc Form. You must fulfill thefollowing 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 namedUpdateDatabase.4. Additional forms similar to Abc Form must be created for other tables in thedatabase.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 theAbc 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 theAbc 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 theAbc 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 toAbc Form.Repeat this process for the other forms.Answer: CExplanation: We combine multiple Windows Form controls into a single control,called user control. This is the most efficient solution to reuse functionality in thisscenario.Note: Sometimes, a single control does not contain all of the functionality you need. Forinstance, you might want a control that you can bind to a data source to display a firstname, last name, and phone number, each in a separate TextBox. Although it is possibleto implement this logic on the form itself, it might be more efficient to create a singlecontrol that contains multiple text boxes, especially if this configuration is needed inmany different applications. Controls that contain multiple Windows Forms controlsbound together as a single unit are called user controls.Reference: 70-306/70-316 Training kit, Inheriting from UserControl, Page 345Incorrect AnswersA: 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 areexecuted 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 bymany developers in your company Abc Inc. FormattedTextBox will be updatedfrequently.You create a custom bitmap image named CustomControl.bmp to representFormattedTextBox in the Visual Studio .NET toolbox. The bitmap contains thecurrent version number of the control, and it will be updated each time the controlis updated. The bitmap will be stored in the application folder.If the bitmap is not available, the standard TextBox control bitmap must bedisplayed instead.Which class attribute should you add to FormattedTextBox?A. [ToolboxBitmap(typeof(TextBox))[class FormattedTextBoxB. [ToolboxBitmap(@"CustomControl.bmp")]class FormattedTextBoxC. [ToolboxBitmap(typeof(TextBox), "CustomControl.bmp")]class FormattedTextBoxD. [ToolboxBitmap(typeof(TextBox))][ToolboxBitmap(@"CustomControl.bmp")]class FormattedTextBoxAnswer: BExplanation: You specify a Toolbox bitmap by using the ToolboxBitmapAttributeclass. The ToolboxBitmapAttribute is used to specify the file that contains thebitmap.Reference: 70-306/70-316 Training kit, To provide a Toolbox bitmap for your control,Page 355-356Incorrect AnswersA, C, D: If you specify a Type (type), your control will have the same Toolbox bitmap asthat of the Type (type) you specify.# QUES:You use Visual Studio .NET to develop a Windows-based application that contains asingle form. This form contains a Label control named labelCKValue and a TextBoxcontrol named textCKValue. labelCKValue displays a caption that identifies thepurpose of textCKValue.You want to write code that enables users to place focus in textCKValue when theypress ALT+V. This key combination should be identified to users in the display oflabelCKValue.Which three actions should you take? (Each correct answer presents part of thesolution. 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, FExplanation: If the UseMnemonic property is set to true (A) and a mnemoniccharacter (a character preceded by the ampersand) is defined in the Text propertyof the Label (B), pressing ALT+ the mnemonic character sets the focus to thecontrol that follows the Label in the tab order (F). You can use this property toprovide proper keyboard navigation to the controls on your form.Note1 The UseMnemonic property gets or sets a value indicating whether the controlinterprets an ampersand character (&) in the control's Text property to be an access keyprefix 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 AnswersC, 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 labelcontrol.G, H: This is not necessary. It has no effect here.# QUES:You use Visual Studio .NET to create a Windows-based application calledAbc Mortage. The main form of the application contains several check boxesthat correspond to application settings. One of the CheckBox controls is namedadvancedCheckBox. 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 thesolution. 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, CExplanation:A: The AutoCheck property must be set to True so that the CheckBox automatically ischanged when the check box is accessed.C: The Text property contains the text associated with this control. By using the &-signwe define a shortcut command for this control. "@Advanced" defines the shortcutALT+A.Reference:.NET Framework Class Library, CheckBox Properties.NET Framework Class Library, CheckBox.AutoCheck Property [C#]Incorrect AnswersB: If AutoCheck is set to false, you will need to add code to update the Checked orCheckState 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 sameinformation in many different applications. The control must always be displayed atthe bottom of the parent form in every application. It must always be as wide as theform. When the form is resized, the control should be resized and repositionedaccordingly.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: CExplanation:DockStyle.Bottom docks the control to the bottom of the form. This will force the controlto 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 FormsNET Framework Class Library, AnchorStyles Enumeration [C#]Incorrect AnswersA: 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 aWindows-based application. You need to make the application accessible to userswho 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 speakingthe word "name" when a user changes focus to this control.Which property of this control should you configure?A. TagB. NextC. NameD. AccessibleNameE. AccessibleRoleAnswer: DExplanation: The AccessibleName property is the name that will be reported to theaccessibility aids.Reference:Visual Basic and Visual C# Concepts, Providing Accessibility Information for Controlson a Windows FormVisual Basic and Visual C# Concepts, Walkthrough: Creating an Accessible WindowsApplicationIncorrect AnswersA, B, C: The Tag, Next and Name properties of a control is not used directly byaccessibility 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 applicationincludes 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, FExplanation: We disable the Minimize and Maximize buttons with theXyz Form.Minimizebox and the Xyz Form.Maximizebox properties.Furthermore we should use a fixed FormBorderStyle to prevent the users frommanually 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 AbcInc. The application includes a form that contains several controls, including abutton named exitButton. After you finish designing the form, you select all controlsand then select Lock Controls from the Format menu.Later, you discover that exitButton is too small. You need to enlarge its verticaldimension with the least possible effort, and without disrupting the other controls.First you select exitButton in the Windows Forms Designer. What should you donext?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 itsform 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, andTop properties.When you compile this code, you receive an error message indicating thatButtonHandler is not declared.You need to add a ButtonHandler routine to handle the Click event for alldynamically added Button controls.Which declaration should you use for ButtonHandler?A. public void ButtonHandler()B. public void ButtonHandler(System.Windows.Forms.Buttonsender)C. public void ButtonHandler(System.Object sender)D. public void ButtonHandler(System.Windows.Forms.Buttonsender, 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 orderdetails. 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. Thisobject includes one column named Quantity and another named UnitPrice. For eachitem on a purchase order, your application must display a line item total in aDataGrid control on Display Abc Form. The line item is the product of Quantitytimes UnitPrice. Your database design does not allow you to store calculated valuesin the database.You need to add code to your Form_Load procedure to calculate and display theline 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: AExplanation: We use the Expression property of the DataColumn object calculatethe 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 AnswersB: The Equals method cannot be used in this way. The equals method is used to test ifdifferent 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 beused only by developers who purchase a license to use it.You decide to use a license provider implemented by the LicFileLicenseProviderclass. 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 ofthe 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 onlinegaming. Each user will run the client version of the application on his or her localcomputer. In the game, each user controls two groups of soldiers, Group1 andGroup2.You create a top-level menu item whose caption is Groups. Under this menu, youcreate 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 userselect the Groups menu, the two submenus will be displayed. The user can selectonly one group of soldiers at a time.You must ensure that a group can be selected either by clicking the appropriatesubmenu item or by holding down the ALT key and pressing 1 or 2. You must alsoensure that the group currently select will be indicated by a dot next to thecorresponding submenu item. You do not want to change the caption text of any ofyour menu items.Which four actions should you take? (Each correct answer presents part of thesolution. 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, GExplanation: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 themenu item is selected. We should set the clicked Submenu Checked property to True, andthe other Submenu Checked property to False.G: The menu item's RadioCheck property customizes the appearance of the selectedReference:Visual Basic and Visual C# Concepts, Adding Menu Enhancements to Windows FormsVisual Basic and Visual C# Concepts, Introduction to the Windows Forms MainMenuComponentIncorrect AnswersA: 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 DataSetobject to maintain a working set of data for your users. Users frequently changeinformation in the DataSet object. Before you update your database, you must rundata validation code on all user changes.You need to identify the data rows that contain changes. First you create aDataView 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: DCorrect answer is "Set the RowStateFilter property toModifiedCurrent", this will shows changed rows and the current values.# QUES:You develop a Windows-based orderentry application Abc App. Theapplication uses a DataSet object named customerDataSet to manage client datawhile users edit and update customer records. The DataSet object contains aDataTable object named creditAuthorizationDataTable. This object contains a fieldnamed MaxCredit, which specifies the credit limit for each customer.Customer credit limits cannot exceed $20,000. Therefore, Abc App must verifythat users do not enter a larger amount in MaxCredit. If a user does so, the usermust be notified, and the error must be corrected, before any changes are storedpermanently in the database.You create a procedure named OnRowChanged. This procedure sets theDataTable.Row.RowError property for each row that includes an incorrect creditlimit. You also enable the appropriate event handling so OnRowChanged is called inreaction to the RowChanged event of the DataTable object. OnRowChanged willrun 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 rowsthat are marked as having an error. Which code segment should you use?A. foreach (DataRow myRow increditAuthorizationDataTable.GetErrors()) {MessageBox.Show(String.Format("CustID = {0}, Error = {1}",MyRow["CustID"] . myRow.RowError) ) ;}B. foreach (DataRow myRow increditAuthorizationDataTable.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: AExplanation: GetErrors method gets an array of DataRow objects that containerrors. We use the GetErrors method to get retrieve all rows that contain errors.Reference: .NET Framework Class Library, DataRow.RowError Property [C#]Incorrect AnswersB: The HasErrors property is used to determine if a DataRow contains errors. It returns aBoolean 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 containerrors.# QUES:You develop a Windows-based application Abc App that includes severalmenus. Every top-level menu contains several menu items, and certain menuscontain items that are mutually exclusive. You decide to distinguish the single mostimportant 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: AExplanation: Gets or sets a value indicating whether the menu item is the defaultmenu item. The default menu item for a menu is boldfaced.Reference: .NET Framework Class Library, MenuItem.DefaultItem Property [C#]Incorrect AnswersB: The Text property contains the text that is associated with the control. We cannotformat 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 themenu 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 toedit personal information such as address and telephone number. The form containsa text box named textPhoneNumber.If a user enters an invalid telephone number, the form must notify the user of theerror. You create a function named IsValidPhone that validates the telephonenumber entered. You include an ErrorProvider control named ErrorProvider1 inyour 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: AExplanation: The Validating event allows you to perform sophisticated validationon controls. It is possible to use an event handler that doesn't allow the focus toleave the control until a value has been entered.The ErrorProvider component provides an easy way to communicate validation errors tousers. The SetError method of the ErrorProvider class sets the error description string forthe specified control.Note: Focus events occur in the following order:1. Enter2. GotFocus3. Leave4. Validating5. Validated6. LostFocusReference: 70-306/70-316 Training kit, To create a validation handler that uses theErrorProvider component, Pages 93-94.NET Framework Class Library, ErrorProvider.SetError Method [C#]Incorrect AnswersC: The GetError method returns the current error description string for the specifiedcontrol.E: The updateBinding method provides a method to update the bindings of theDataSource, DataMember, and the error text. However, we just want to set the errordescription.B, D, F: The validated event occurs when the control is finished validating. It can used toperform any actions based upon the validated input.# QUES:You work as a software developer at Abc .com. You develop a Windows-basedapplication that includes two objects named Abc Contact andAbc Employee. Abc Employee inherits from Abc Contact, andAbc Contact exposes an event named DataSaved. You want to raise theDataSaved event from Abc Employee.What should you do?A. Call the RaiseEvent method from Abc Employee and pass DataSaved as the eventname.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 explicitlyraises the DataSaved event.Call RaiseDataSaved from Abc Employee.D. In Abc Employee, create a protected method named RaiseDataSaved thatexplicitly 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. Theapplication includes several menu controls that provide access to most of theapplication's functionality.One menu option is named calculateOption. When a user chooses this option, theapplication will perform a series of calculations based on information previouslyentered by the user.To provide user assistance, you create a TextBox control named Abc Help. Thecorresponding text box must display help information when the user pauses on themenu 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 theIn which event should you add this code segment?A. calculateOption_ClickB. calculateOption_PopupC. calculateOption_SelectD. calculateOption_DrawItemE. calculateOption_MeasureItemAnswer: CExplanation: The Select event is raised when a menu item is highlighted. We shoulduse the Select event to set the helper text.Reference: 70-306/70-316 Training kit, Using Menu Item Events, Page 79Incorrect AnswersA: 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. Itcan 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 performdrawing 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 itembefore drawing it.# QUES:You develop a Windows-based application that will retrieve Abc employeevacation data and display it in a DataGrid control. The data is managed locally in aDataSet 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. Theapplication retrieves a list of contacts from a central database. The list is managedlocally in a DataSet object named listDataSet, and it is displayed in a DataGridcontrol.You create a procedure that will conduct a search after you enter a combination ofpersonal name and family name. You application currently includes the followingcode 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 familyname 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: AExplanation: We load the search parameters into an array. We use two separatevalues. The first value is the FamilyName and the second is PersonalName as it isused 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 306Incorrect AnswersB, D: There are two columns. We must separate the Family name and the Personal intotwo separate strings.C: Wrong order of the search parameters. The family name Bill must be the first searchparameter.
# QUES:You use Visual Studio .NET to create a Windows-based application. On the mainapplication form, Abc FormMain, you create a TextBox control namedtextConnectionString. Users can enter a database connection string in this box toaccess customized data from any database in your company.You also create a Help file to assist users in creating connection strings. The Helpfile will reside on your company intranet.Your application must load the Help file in a new browser window when the userpresses F1 key, but only of textConnectionString has focus. You must create thisfunctionality by using the minimum amount of code.In which event should you write the code to display the Help file?A. textConnectionString_KeyPressB. textConnectionString_KeyDownC. textConnectionString_KeyUpD. textConnectionString_GiveFeedbackE. textConnectionString.HelpReabctedAnswer: EExplanation: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 oran associated context-sensitive help button is clicked. This would be the moststraightforward solution and would require minimal code.Note: Key events occur in the following order:1. KeyDown2. KeyPress3. KeyUpReference:.NET Framework Class Library, Control.HelpReabcted Event [C#].NET Framework Class Library, Control.KeyDown Event [C#]Incorrect AnswersA: The KeyPress event occurs when a key is pressed while the control has focus. TheKeyPress 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 applicationcaptures screen shots of a small portion of the visible screen.You create a form named Abc CameraForm. You set theAbc CameraForm.BackColor property to Blue. You create a button on theform to enable users to take a screen shot.Now, you need to create a transparent portion of Abc CameraForm to frame asmall portion of the screen. Your application will capture an image of the screeninside the transparent area. The resulting appearance of Xyz i ngCameraForm isshown 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 thesolution. 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, FExplanation: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 isBlue.
# QUES:You work as software developer at Abc inc. You need to develop a Windowsform that provides online help for users. You want the help functionality to beavailable when users press the F1 key. Help text will be displayed in a pop-upwindow for the text box that has focus.To implement this functionality, you need to call a method of the HelpProvidercontrol and pass the text box and the help text.What should you do?A. SetShowHelpB. SetHelpStringC. SetHelpKeywordD. ToStringAnswer: BExplanation:To associate a specific Help string with another control, use the SetHelpStringmethod. The string that you associate with a control using this method is displayedin 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 FormsHelpProvider Component# QUES:You develop a Windows-based application. Its users will view and edit employeeattendance data. The application uses a DataSet object named customerDataSet tomaintain the data while users are working with it.After a user edits data, business rule validation must be performed by a middle-tiercomponent named Xyz Component. You must ensure that your application sendsonly 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. Yourapplication will display customer order information from a Microsoft SQL Serverdatabase. The orders will be displayed on a Windows Form that includes aDataGrid control named Abc Grid1. Abc Grid1 is bound to a DataViewobject. Users will be able to edit order information directly in Abc Grid1.You must give users the option of displaying only edited customer orders andupdated values in Abc Grid1.What should you do?A. Set the RowStateFilter property of the DataView object toDataViewRowState.ModifiedOriginal.B. Set the RowStateFilter property of the DataView object toDataViewRowState.ModifiedCurrent.C. Set the RowFilter property of the DataView object toDataViewRowState.ModifiedOriginal.D. Set the RowFilter property of the DataView object toDataViewRowState.ModifiedCurrent.Answer: BExplanation: We must set the RowStateFilter property of the DataView to specifywhich version or versions of data we want to view. We should use theModifiedCurrent. DataViewRowState which provides the modified version oforiginal data.Reference:.NET Framework Class Library, DataViewRowState Enumeration [C#]Incorrect AnswersA, C: The ModifiedOriginal DataViewRowState is used to get the original version of therows 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 aRowStateFilter.# QUES:As a developer at Abc you develop a new salesanalysis application that reusesexisting data access components. One of these components returns a DataSet objectthat contains the data for all customer orders for the previous year.You want your application to display orders for individual product numbers. Userswill 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 filterexpression.Answer: CExplanation: You filter data by setting the RowFilter property. The RowFilterproperty takes a String that can evaluate to an expression to be used for selectingrecords. RowFilter is a property of the DataView object.Reference: Visual Basic and Visual C# Concepts, Filtering and Sorting Data Using DataViewsIncorrect AnswersA: 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, andUnchanged.# QUES:You develop a Windows-based application Xyz . Xyz uses a DataSet object thatcontains two DataTable objects. Xyz will display data from two data tables. Onetable contains customer information, which must be displayed in a data-boundListBox control. The other table contains orderinformation, which must bedisplayed 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: DExplanation: You can use a DataRelation to retrieve parent and child rows. Relatedrows are retrieved by calling the GetChildRows or GetParentRow methods of aDataRow.Note: A DataRelation object represents a relationship between two columns of data indifferent tables. The DataRelation objects of a particular DataSet are contained in theRelations property of the DataSet. A DataRelation is created by specifying the name ofthe DataRelation, the parent column, and the child column.Reference: 70-306/70-316 Training kit, Retrieving Related Records, Page 286Incorrect AnswersA: The Merge method is used to merge two DataSet objects that have largely similarschemas. 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, itwould not help in retrieving related records.# QUES:You develop a Windows-based application to manage business contacts. Theapplication 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 cityname into a TextBox control.The list of contacts that match this name must then be displayed in a DataGridcontrol.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: BExplanation: To form a RowFilter value, specify the name of a column followed byan operator and a value to filter on. The value must be in quotes. Here we useconstruct the rowfilter with the = operator, string concatenation (&) and theTextBox1.Text property.Reference: .NET Framework Class Library, DataView.RowFilter Property [C#]Incorrect AnswersA: 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 interactswith a Microsoft SQL Server database. Your application contains a form namedCustomerForm. 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 theappropriate column in the DataTable object of Abc DataSet. When you test theapplication, you can successfully connect to the database. However, no data isdisplayed in any text boxes.You need to modify your application code to ensure that data is displayedappropriately. Which behavior should occur while the CustomerForm.Load eventhandler is running?A. Execute the Add method of the TextBoxes DataBindings collection and pass inAbc 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 inAbc DataSet.E. Execute the Fill method of Abc DataAdapter and pass in Abc DataSet.Answer: EExplanation: Dataset is a container; therefore, you need to fill it with data. You canpopulate 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. Youadd a custom control named BarGraph, which displays numerical data. You createa second custom control named DataBar. Each instance of DataBar represents onedata value in BarGraph.BarGraph retrieves its data from a Microsoft SQL Server database. For each datavalue that it retrieves, a new instance of DataBar is added to BarGraph. BarGraphalso includes a Label control named DataBarCount, which displays the number ofDataBar controls currently contained by BarGraph.You must add code to one of your custom controls to ensure that DataBarCount isalways updated with the correct value.What are two possible ways to achieve this goal? (Each correct answer presents acomplete 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, EExplanation: We could either catch the ControlAdded event, or add code theconstructor.C: The Control.ControlAdded Event occurs when a new control is added to theControl.ControlCollection. When a control is added to BarGraph we could set the countof 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 AnswersA, 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 thefollowing design-time controls:1. SQLConnection object named Abc Connection2. SQLDataAdapter object named Abc DataAdapter3. DataSet object named CustomerDataSet4. Five TextBox controls to hold the values exposed by CustomerDataSet5. Button control named saveButtonAt design time you set the DataBindings properties of each TextBox control to theappropriate column in the DataTable object of CustomerDataSet.When the application runs, users must be able to edit the information displayed inthe text boxes. All user changes must be saved to the appropriate database whensaveButton is executed. The event handler for saveButton includes the followingcode segment:Abc DataAdapter.Update(CustomerDataSet);You test the application. However, saveButton fails to save any values edited in thetext 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 inAbc Connection.C. Before calling the Update method, ensure that a row position change occurs inCustomerDataSet.D. Reestablish the database connection by calling the Open method ofAbc Connection.Answer: CExplanation: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 anaccounting application, which contains a substantial amount of code. Sometimes adeveloper cannot complete a portion of code until dependencies are completed byanother developer. In these cases, the developer adds a comment in the applicationcode about the work left incomplete. Such comments always begin with theUNDONE.You open the application code on your computer. As quickly as possible, you needto 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 theentire solution.C. Open a code window and use the Find in Files dialog box to search the applicationcode for UNDONE.D. Open a code window and use the Find dialog box to search all open documents forUNDONE.Answer: AExplanation: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 exposesa method named GetCurrentRate. Abc 3 uses GetCurrentRate to obtain thecurrent mortgage interest rate.Six months after you deploy Abc 3, users begin reporting errors. You discoverthat MortgageRate has been modified. GetCurrentRate now requires you to pass apostal code before returning the current mortgage interest rate.You must ensure that Abc 3 consumes the most recent version ofMortgageRate. 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 inAbc 3.D. Use the Add Reference dialog box to recreate the reference to MortgageRate inAbc 3.E. Remove the reference to MortgageRate in Abc 3. Use the Add Web Referencedialog box to create the reference.Answer: CExplanation: If your application contains a Web reference to an XML Web servicethat has been recently modified on the server, you may need to update the referencein your project.To update a project Web reference1. In Solution Explorer, access your project's Web References folder and select the nodefor 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, thatwill be used by other applications, including a standard COM client application.You must deploy your assembly on the COM application to a client computer. Youmust ensure that the COM application can instantiate components within theassembly 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: BExplanation: The Assembly Registration tool reads the metadata within an assembly andadds the necessary entries to the registry, which allows COM clients to create .NETFramework classes transparently. Once a class is registered, any COM client can use it asthough 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 AnswersA: The Strong Name tool helps sign assemblies with strong names.C: The Type Library Importer, tlbimp.exe, converts the type definitions found within aCOM type library into equivalent definitions in a common language runtime assembly. Itwould 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 accountingapplication, which contains a class named Abc Accounts. This class instantiatesseveral classes from a COM component that was created by using Visual Basic 6.0.Each COM component class includes a custom method named ShutDownObjectthat must be called before terminating references to the class.Software testers report that the COM component appears to remain in memoryafter the application terminates. You must ensure that the ShutDownObject methodof 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 ShutDownObjectmethod of each COM component class.B. Find each location in your code where a reference to Abc Accounts is set to nullor goes out of scope.Add code after each instance to manually invoke the Visual Studio .NET garbagecollector.C. Add a destructor to Abc Accounts.Add code to the destructor to call the ShutDownObject method of each COM componentclass.D. Add the procedure private void Finally() to Abc Accounts.Add code to the procedure to call the ShutDownObject method of each COM componentclass.Answer: CExplanation: Be creating a destructor for Abc Accounts class we can ensurethat 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 theAbc company. The application consists of a user interface and several XMLWeb services. You develop all XML Web services and perform unit testing. Nowyou are ready to write the user interface code.Because some of your servers are being upgraded, the XML Web service thatprovides mortgage rates is currently offline. However, you have access to itsdescription 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 localdevelopment computer.D. Add the description file for the XML Web service to your Visual Studio .NET project.Answer: BExplanation:Ordinarily to access an XML Web service from a client application, you first add a Webreference, which is a reference to an XML Web service. When you create a Webreference, Visual Studio creates an XML Web service proxy class automatically and addsit to your project.However, you can manually generate a proxy class using the XML Web servicesDescription Language Tool, Wsdl.exe, used by Visual Studio to create a proxy classwhen adding a Web reference. This is necessary when you are unable to access the XMLWeb service from the machine on which Visual Studio is installed, such as when theXML Web service is located on a network that will not be accessible to the client untilrun time. You then manually add the file that the tool generated to your applicationproject.Reference:Visual Basic and Visual C# Concepts, Locating XML Web ServicesVisual Basic and Visual C# Concepts, Generating an XML Web Service Proxy
# QUES:You use Visual Studio .NET to create an application. Your application contains twoclasses, Region and City, which are defined in the following code segment. (Linenumbers 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 theCalculate 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 resourcesdepartment 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 actualemployees in your company should be represented by interfaces that are derivedfrom IEmployee.Now you need to create a class named Manager to represent executives in yourcompany. 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 thatapply)A. public class Manager:IExecutiveB. public class Manager:IEmployee, IExecutiveC. public class Manager:IEmployeeD. public class Manager:IExecutive, IEmployeeE. public double Salary()F. public double AnnualBonus()Answer: A, E, FA: A class can implement an Interface. The Manager class should implement theIExecutive interface.E, F: The properties that are defined in the Interface must be implemented in a Class.Incorrect AnswersB: 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 definesbusiness rules and performs calculations based on those rules. Other developers inyour company must not be able to override the functions and subroutines defined inXyz BusinessRules with their own definitions.Which two actions should you take to create BusinessRules? (Each correct answerpresents 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 BusinessRulesE. Use the following code segment to define BusinessRules:public new class Xyz BusinessRulesF. Use the following code segment to define BusinessRules:public sealed class Xyz BusinessRulesG. Use the following code segment to define BusinessRules:public abstract class Xyz BusinessRulesAnswer: B, FExplanation:B: You can use the Class Library template to quickly create reusable classes andcomponents 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 theclass.Reference:Visual Basic and Visual C# Concepts, Class Library TemplateC# Programmer's Reference, sealed70-306/70-316 Training kit, Creating Classes That Cannot Be Inherited, Page 182Incorrect AnswersA: The Windows Control Library project template is used to create custom controls touse on Windows Forms.C: When you create a service, you can use a Visual Studio .NET project template calledWindows Service. However, we want to implement Business rules, not network services.D: A protected class will hide properties from external classes and thus keep thisfunctionality 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'teven create class with that syntax, so it surely dont let the developers to inherit from (norto override it's members).G: The abstract modifier is used to indicate that a class is incomplete and that it isintended to be used only as a base class.# QUES:You use Visual Studio .NET to create a Windows-based application that will trackAbc sales. The application's main object is named Abc . The Abc class iscreated by the following definition:public class Abc {}You write code that sets properties for the Abc class. This code must beexecuted 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 codesegment 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: AExplanation: We must create a constructor for the class. We wrote a method whosename is the same as the name of the class, and we specify not return type, not evenvoid.Reference: Visual C# Step by step, page 144Incorrect AnswersB, C: We cannot specify any return type, not even void, when we define a constructor fora 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 ofMicrosoft Windows XP Professional distributed in France. These files containfinancial transaction information, including dates, times, and monetary values. Thedata is stored in a culture-specific format.You develop an application Abc Interactive, which uses these data files. Youmust ensure that Abc Interactive correctly interprets all the data, regardless ofthe 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: CExplanation: The CultureInfo represents information about a specific cultureincluding the names of the culture, the writing system, and the calendar used, aswell as access to culture-specific objects that provide methods for commonoperations, such as formatting dates and sorting strings.Reference: 70-306/70-316 Training kit, Getting and Setting the Current Culture, Pages403-404.NET Framework Class Library, CultureInfo Class [C#]Incorrect AnswersA: We must use the System.Globalization namespace, not the System.Data namespaceB, 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 namedAbc Component. Your application uses namespaces exposed byAbc Component.You must deploy both Abc Client and Abc Component to severalcomputers in your company's accounting department. You must also ensure thatAbc Component can be used by future client applications.What are three possible ways to achieve your goal? (Each correct answer presents acomplete solution. Choose three)A. Deploy Abc Client and Abc Component to a single folder on each clientcomputer.Each time a new client application is developed, place the new application in its ownfolder and copy Abc Component to the new folder.B. Deploy Abc Client and Abc Component to a single folder on each clientcomputer.Each time a new client application is developed, place the new application in its ownfolder.Edit Abc Client.exe.config and add a privatePath tag that points to the folder whereAbc Component is located.C. Deploy Abc Client and Abc Component to separate folders on each clientcomputer.In each client application that will use Abc Component, add the following codesegment: using Abc Component;D. Deploy Abc Client and Abc Component to separate folders on each clientcomputer.Each time a new client application is developed, select Add Reference from the Toolsmenu and add a reference to Abc Component.E. Deploy Abc Client and Jack CBill Component to separate folders on each clientcomputer.Register Abc Component on each client computer by using the RegSvr32 utility.F. Deploy Abc Client and Abc Component to separate folders on each clientcomputer.Add Abc Component to the global assembly cache.Answer: A, B, FExplanation:A: XCOPY deployment of the Abc Component, we simply copy the component tothe 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 intothe 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 GlobalAssembly CacheC# Programmer's Reference, using DirectiveIncorrect AnswersC: 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 (FileNotFoundexception).E: RegSrv32 was used in before the introduction of Visual Studio .NET to register .dllfile. 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. Userinterface elements on the form need to conform to this alignment.You must ensure that all user interface elements are properly formatted when thelocalized Windows Form runs. You must also ensure that Abc Local is easy toupdate 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: BExplanation: The RightToLeft property is used for international applications wherethe language is written from right to leftReference:Visual Basic and Visual C# Concepts, Displaying Right-to-Left Text in Windows Formsfor GlobalizationIncorrect AnswersA: The RightToLeft property can be set either to controls or to the form. The bestsolution 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 yourWindows-based application. The form contains a command button namedcheck Abc Button. When check Abc Button is clicked, the application mustcall a procedure named Get Abc .Which two actions should you take? (Each correct answer presents part of thesolution. Choose two)A. Add arguments to the Get Abc declaration to accept System.Object andSystem.EventArgs.B. Add arguments to the check Abc Button_Click declaration to acceptSystem.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.ClickE. Add the following code segment at the end of the check Abc Button_Clickprocedure:Handles Get AbcAnswer: B, D# QUES:You develop an inventory management application for Abc . The applicationuses a SqlDataReader object to retrieve a product code list from a database. The listis displayed in a drop-down list box on a Windows Form.The Form_Load procedure contains the following code. (Line numbers are includedfor reference only)01 public void ReadMyData (String ConnectionString)02 {03 String query =04 "SELECT CatID, CatName FROM Abc Categories";05 SqlConnection cnn = new06 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 insertadditional code on line 10. Your insertion must minimize the use of database server resources withoutadversely 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 AbcInc. The application enables users to update customer information that is stored in adatabase.Your application contains several text boxes. All TextBox controls are validated assoon as focus is transferred to another control. However, your validation code doesnot function as expected. To debug the application, you place the following line ofcode in the Enter event handler for the first text box:You repeat the process for the Leave, Validated, Validating, and TextChangedevents. In each event, the text is displayed in the output window contains the nameof the event being handled.You run the application and enter a value in the first TextBox control. Then youchange 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 ValidatedB. Enter TextChanged Leave Validating ValidatedC. Enter Validating Validated TextChanged LeaveD. Enter TextChanged Validating Validated LeaveE. Enter Validating TextChanged Validated LeaveAnswer: B# QUES:You create the user interface for a Windows-based application. The main form inyour application includes an Exit menu item named exitItem and an Exit buttonnamed 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 exitcode. }Answer: A# QUES:You use Visual Studio .NET to create a component named Reabct. This componentincludes a method named AcceptCKReabct, which tries to process new userreabcts for services. AcceptCKReabct calls a private function named Validate.You must ensure that any exceptions encountered by Validate are bubbled up to theparent form of Reabct. The parent form will then be responsible for handling theexceptions. You want to accomplish this goal by writing the minimum amount ofcode.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: AExplanation: The unhandled exception automatically will be thrown to the clientapplication. This solution meets the requirement that the least amount of codeshould be used.Not B: Options A and B produce the same result. Option A is better solution because ofminimized coding. Catching and just throwing an exception in the catch block, withoutany additional processing is meaningless.# QUES:You use Visual Studio .NET to create a Windows-based application. The applicationincludes a form named Abc . You implement print functionality in Abc byusing the native .NET System Class Libraries.Abc will print a packing list on tractor-fed preprinted forms. The packing listalways consists of two pages. The bottom margin of page 2 is different from thebottom 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 theQueryPageSettingEventArgs 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: BExplanation:It is possible to print each page of a document using different page settings. You set pagesettings by modifying individual properties of theQueryPageSettingsEventArgs.PageSettings property. Changes made to the PageSettingsaffect 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 tospecify 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 AnswersA: 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 applicationincludes a form named Abc Procedures (CKP). CKP allows users to enter verylengthy text into a database. When users click the Print button located on CKP, thistext must be printed by the default printer. You implement the printingfunctionality by using the native .NET System Class Libraries with all defaultsettings.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 objectto True.B. In the EndPrint event, set the HasMorePages property of the PrintEventArgs object toTrue.C. In the PrintPage event, set the HasMorePages property of the PrintPageEventArgsobject to True.D. In the QueryPageSettings event, set the HasMorePages property of theQueryPageSettingEventArgs object to True.Answer: CExplanation: PrintDocument.PrintPage Event occurs when the output to print forthe current page is needed. This event has the HasMorePages property which getsor 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 isdefined 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 theContactSaved event raised by the Contact object. The Contact object will beinitialized 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: CExplanation: 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 yourdesired 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-144Incorrect AnswersA: 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 mustbe used:new EventHandler(HandleContactSaved)
# QUES:You are a developer for a Abc Inc that provides free software over theInternet. You are developing en e-mail application that users all over the world candownload.The application displays text strings in the user interface. At run time, these textstrings must appear in the language that is appropriate to the locale setting of thecomputer running the application.You have resources to develop versions of the application for only four differentcultures. You must ensure that your application will also be usable by people ofother 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: CExplanation: When you build a project, the resource files are compiled and thenembedded in satellite assemblies, or assemblies which contain only the localizedresources. The fallback resources are built into the main assembly, which alsocontains the application code.Reference:Visual Basic and Visual C# Concepts, What's New in International ApplicationsVisual Basic and Visual C# Concepts, Introduction to International Applications inVisual Basic and Visual C#Incorrect AnswersA: 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. Theapplication includes a COM component that you created.Abc .com company policy requires you to sign the Abc Op assembly with astrong name. However, issues of company security require that you delay signingthe assembly for one month. You need to begin using the application immediately ona 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 theSystem.Runtime. Abc OpServices namespace.D. Create a custom wrapper by creating a duplicate definition or interface of the class inmanaged source code.Answer: BExplanation: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 acommon class library assembly named Abc Customers. You deploy theapplication to client computers on your company intranet.Later, you modify Abc Customers.Any application that uses version 1.0.0.0must 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: CExplanation: When an assembly vendor releases a new version of an assembly, thevendor can include a publisher policy so applications that use the old version nowuse the new version.Reference:.NET Framework General Reference, Element# QUES:Your company uses Visual Studio .NET to create a Windows-based application forAbc . The application is named CustomerTracker, and it calls an assemblynamed Schedule.Six months pass. The hospital asks your company to develop a new Windows-basedapplication. The new application will be named EmployeeTracker, and it will alsocall Schedule. Because you anticipate future revisions to this assembly, you wantonly one copy of Schedule to serve both applications.Before you can use Schedule in EmployeeTracker, you need to complete somepreliminary tasks.Which three actions should you take? (Each correct answer presents part of thesolution. 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, EExplanation: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 theglobal 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 GlobalAssembly Cache.NET Framework Developer's Guide, Side-by-Side ExecutionIncorrect AnswersB: Side-by-side execution is the ability to run multiple versions of the same assemblysimultaneously. It is not required in this scenario.D: The assembly should be moved to the global assembly cache, not to theWindows\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 otherVisual Studio .NET applications. No Permissions should be granted to this assemblyunless the assembly makes a minimum permission reabct for them.Which code segment should you use?A. B. C. D. Answer: DExplanation: The ReabctOptional SecurityAction reabcts for additionalpermissions that are optional (not required to run). This action can only be usedwithin the scope of the assembly. The code needs only the minimum set ofpermissions and no others. It should not be granted any optional permissions that ithas not specifically reabcted. We must therefore use Unrestricted := False.Reference:.NET Framework Developer's Guide, Reabcting Optional PermissionsIncorrect Answers:A, B: The PermitOnlySecurityAction does not support Assembly as a target, it only supports Class or Methodas targets.C: The assembly must only be granted minimal permissions. It should not be granted anyoptional 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 namedsp_UpdatePrices.sp_UpdateCKPrices performs a SQL UPDATE statement that increases prices forselected 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 andreturns the results to a SqlDataReader object. The SqlDataReader object gives youaccess to the data in the result set. Which is displayed in a list box on your WindowsForm.The value of @totalprice must also be displayed in a text box on your WindowsForm. 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.closeC.TextBox1.Text=com.parameters["@totalprice"].value.ToString(); reader.close(); D.reader.close();TextBox1.Text= com.parameters["@totalprice"].value.ToString(); A.cmd.executeNonQuery();Answer:DExplanation: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. Theassembly will reside on the client computer when the application is installed. Youmust ensure that any future applications installed on the same computer can accessthe assembly.Which two actions should you take? (Each correct answer presents part of thesolution. 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, FExplanation:The global assembly cache stores assemblies specifically designated to be shared byseveral 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 deploymentproject.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 GlobalAssembly Cache.NET Framework Developer's Guide, Installing an Assembly into the Global AssemblyCache# QUES:You use Visual Studio .NET to create a control that will be used on several forms inyour application. It is a custom label control that retrieves and displays yourcompany's current stock price.The control will be displayed on many forms that have different backgrounds. Youwant the control to show as much of the underlying form as possible. You want toensure that only the stock price is visible. The rectangular control itself should notbe 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 thesolution. Choose two)A. ContextMenu1.MenuItems.Clear();B. ContextMenu1.MenuItems.Add("&Display Help");C. ContextMenu1.MenuItems.Add(helpCKOption.CloneMenu();D. ContextMenu1.MenuItems[0].Click += newSystem.EventHandler(helpCKOption_Click)E. this.SetStyle(ControlStyles.SupportsTransparentBackColor,true )Answer: A, EExplanation: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 yourcontrol's BackColor to Transparent. :this.Backcolor=color.Transparent; Reference: Visual Basic and Visual C# Concepts, Giving YourControl aTransparentBackground# QUES.You are developing a Windows-based application that logs hours worked byAbc employees. Your design goals require you to maximize applicationperformance and minimize impact on server resources.You need to implement a SqlCommand object that will send a SQL INSERT actionquery to a database each time a user makes a new entry.To create a function named LineItemInsert, you write the following code. (Linenumbers 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;0607 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);1314 // Insert new code.15 }You code must execute the SQL INSERT action query and verify the number of database records thatare 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 aMicrosoft SQL Server stored procedure named Abc EmployeeData. Thisprocedure accepts a parameter for querying the database by an employee's familyname.You need to add code to your application to set up the parameter for use with thestored procedure.Which three lines of code should you add? (Each correct answer presents part of thesolution. 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 Serverdatabase. The application includes a form named CustomerForm, which contains aButton control named SortButton. The database includes a table named Customers.Data from Customers will be displayed on CustomerForm by means of a DataGridcontrol 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 ensurethat the data will be displayed in ascending orderby primary key when the userselects 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 DataAdapter object.D. Set the RowFilter property of the DataView object to CustomerID.Answer: AExplanation: The data view definition includes the follow command:dv.sort = "city ASC,contactName ASC"; This enforces sorting on the City and the ContactNamecolumns. Itoverrides the defaultsort order. We must set the Sort property to an empty string. This would enable thedefault sort order.Reference: Visual Basic and Visual C# Concepts, Filtering and Sorting Data Using DataViewsIncorrect AnswersB: By default a view is sorted on the Primary Key in ascending order. We would to setthe 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 calledAbc App. Your application will display customer orderinformation from aMicrosoft SQL Server database. The orders will be displayed on a Windows Formin a data grid named DataGrid1. DataGrid1 is bound to a DataView object.The Windows Form includes a button control named displayBackOrder. Whenusers click this button, DataGrid1 must display only customer orders whoseBackOrder 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: AExplanation: Using the RowFilter property of a data view, you can filter records ina 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 DatasetsVisual Basic and Visual C# Concepts, Filtering and Sorting Data Using Data ViewsIncorrect AnswersB: To filter based on a version or state of a record, set the RowStateFilter property. Itdoes 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 interactswith a Microsoft SQL Server database. Your application contains a form namedCustomerForm, 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 namedCustomers.At run time you add a TextBox control named textCompanyName toCustomerForm. You execute the Fill method of Abc DataAdapter to populateCustomers. Now you want to use data binding to display the CompanyName fieldexposed 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
Certification Id : 070-316
Developing Windows-based Applications.

# 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 ifValid Abc Password returns a value of False. You will add the required code online 6.A. e.Cancel = true;B. sender name;C. password.AcceptsTab = false ;D. password.CausesValidation = false ;Answer: AExplanation: If the input in the control does not fall within required parameters, theCancel property within your event handler can be used to cancel the Validatingevent and return the focus to the control.Reference: 70-306/70-316 Training kit, The Validating and Validated Events, Page 89Incorrect AnswersB: Setting an object to an unknown variable is rubbish.C: The AccptsTab property gets or sets a value indicating whether pressing the TAB keyin a multiline text box control types a TAB character in the control instead of moving thefocus to the next control in the tab order.D: The CausesValidation property gets or sets a value indicating whether validation isperformed when the Button control is clicked.

# Ques:You use Visual Studio .NET to create a Windows-based application. The applicationincludes a form named Abc Form.Abc Form contains 15 controls that enable users to set basic configurationoptions 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 isresized. 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 willnot be displayed correctly. You must ensure that users cannot resizeConfigurationForm to be smaller than 500 x 600 pixels.Which two actions should you take to configure Abc Form? (Each correctanswer 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, HExplanation:A: The Form.MinimumSize Property gets or sets the minimum size the form can beresized 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 beset to "650, 700".Reference:.NET Framework Class Library, Form.MinimumSize Property [C#].NET Framework Class Library, Form.Size Property [C#]Incorrect AnswersB: 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 tomaintain database records in a table named Abc .You need to add several pairs of controls to Abc Form. You must fulfill thefollowing 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 namedUpdateDatabase.4. Additional forms similar to Abc Form must be created for other tables in thedatabase.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 theAbc 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 theAbc 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 theAbc 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 toAbc Form.Repeat this process for the other forms.Answer: CExplanation: We combine multiple Windows Form controls into a single control,called user control. This is the most efficient solution to reuse functionality in thisscenario.Note: Sometimes, a single control does not contain all of the functionality you need. Forinstance, you might want a control that you can bind to a data source to display a firstname, last name, and phone number, each in a separate TextBox. Although it is possibleto implement this logic on the form itself, it might be more efficient to create a singlecontrol that contains multiple text boxes, especially if this configuration is needed inmany different applications. Controls that contain multiple Windows Forms controlsbound together as a single unit are called user controls.Reference: 70-306/70-316 Training kit, Inheriting from UserControl, Page 345Incorrect AnswersA: 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 areexecuted 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 bymany developers in your company Abc Inc. FormattedTextBox will be updatedfrequently.You create a custom bitmap image named CustomControl.bmp to representFormattedTextBox in the Visual Studio .NET toolbox. The bitmap contains thecurrent version number of the control, and it will be updated each time the controlis updated. The bitmap will be stored in the application folder.If the bitmap is not available, the standard TextBox control bitmap must bedisplayed instead.Which class attribute should you add to FormattedTextBox?A. [ToolboxBitmap(typeof(TextBox))[class FormattedTextBoxB. [ToolboxBitmap(@"CustomControl.bmp")]class FormattedTextBoxC. [ToolboxBitmap(typeof(TextBox), "CustomControl.bmp")]class FormattedTextBoxD. [ToolboxBitmap(typeof(TextBox))][ToolboxBitmap(@"CustomControl.bmp")]class FormattedTextBoxAnswer: BExplanation: You specify a Toolbox bitmap by using the ToolboxBitmapAttributeclass. The ToolboxBitmapAttribute is used to specify the file that contains thebitmap.Reference: 70-306/70-316 Training kit, To provide a Toolbox bitmap for your control,Page 355-356Incorrect AnswersA, C, D: If you specify a Type (type), your control will have the same Toolbox bitmap asthat of the Type (type) you specify.# QUES:You use Visual Studio .NET to develop a Windows-based application that contains asingle form. This form contains a Label control named labelCKValue and a TextBoxcontrol named textCKValue. labelCKValue displays a caption that identifies thepurpose of textCKValue.You want to write code that enables users to place focus in textCKValue when theypress ALT+V. This key combination should be identified to users in the display oflabelCKValue.Which three actions should you take? (Each correct answer presents part of thesolution. 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, FExplanation: If the UseMnemonic property is set to true (A) and a mnemoniccharacter (a character preceded by the ampersand) is defined in the Text propertyof the Label (B), pressing ALT+ the mnemonic character sets the focus to thecontrol that follows the Label in the tab order (F). You can use this property toprovide proper keyboard navigation to the controls on your form.Note1 The UseMnemonic property gets or sets a value indicating whether the controlinterprets an ampersand character (&) in the control's Text property to be an access keyprefix 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 AnswersC, 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 labelcontrol.G, H: This is not necessary. It has no effect here.# QUES:You use Visual Studio .NET to create a Windows-based application calledAbc Mortage. The main form of the application contains several check boxesthat correspond to application settings. One of the CheckBox controls is namedadvancedCheckBox. 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 thesolution. 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, CExplanation:A: The AutoCheck property must be set to True so that the CheckBox automatically ischanged when the check box is accessed.C: The Text property contains the text associated with this control. By using the &-signwe define a shortcut command for this control. "@Advanced" defines the shortcutALT+A.Reference:.NET Framework Class Library, CheckBox Properties.NET Framework Class Library, CheckBox.AutoCheck Property [C#]Incorrect AnswersB: If AutoCheck is set to false, you will need to add code to update the Checked orCheckState 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 sameinformation in many different applications. The control must always be displayed atthe bottom of the parent form in every application. It must always be as wide as theform. When the form is resized, the control should be resized and repositionedaccordingly.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: CExplanation:DockStyle.Bottom docks the control to the bottom of the form. This will force the controlto 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 FormsNET Framework Class Library, AnchorStyles Enumeration [C#]Incorrect AnswersA: 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 aWindows-based application. You need to make the application accessible to userswho 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 speakingthe word "name" when a user changes focus to this control.Which property of this control should you configure?A. TagB. NextC. NameD. AccessibleNameE. AccessibleRoleAnswer: DExplanation: The AccessibleName property is the name that will be reported to theaccessibility aids.Reference:Visual Basic and Visual C# Concepts, Providing Accessibility Information for Controlson a Windows FormVisual Basic and Visual C# Concepts, Walkthrough: Creating an Accessible WindowsApplicationIncorrect AnswersA, B, C: The Tag, Next and Name properties of a control is not used directly byaccessibility 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 applicationincludes 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, FExplanation: We disable the Minimize and Maximize buttons with theXyz Form.Minimizebox and the Xyz Form.Maximizebox properties.Furthermore we should use a fixed FormBorderStyle to prevent the users frommanually 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 AbcInc. The application includes a form that contains several controls, including abutton named exitButton. After you finish designing the form, you select all controlsand then select Lock Controls from the Format menu.Later, you discover that exitButton is too small. You need to enlarge its verticaldimension with the least possible effort, and without disrupting the other controls.First you select exitButton in the Windows Forms Designer. What should you donext?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 itsform 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, andTop properties.When you compile this code, you receive an error message indicating thatButtonHandler is not declared.You need to add a ButtonHandler routine to handle the Click event for alldynamically added Button controls.Which declaration should you use for ButtonHandler?A. public void ButtonHandler()B. public void ButtonHandler(System.Windows.Forms.Buttonsender)C. public void ButtonHandler(System.Object sender)D. public void ButtonHandler(System.Windows.Forms.Buttonsender, 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 orderdetails. 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. Thisobject includes one column named Quantity and another named UnitPrice. For eachitem on a purchase order, your application must display a line item total in aDataGrid control on Display Abc Form. The line item is the product of Quantitytimes UnitPrice. Your database design does not allow you to store calculated valuesin the database.You need to add code to your Form_Load procedure to calculate and display theline 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: AExplanation: We use the Expression property of the DataColumn object calculatethe 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 AnswersB: The Equals method cannot be used in this way. The equals method is used to test ifdifferent 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 beused only by developers who purchase a license to use it.You decide to use a license provider implemented by the LicFileLicenseProviderclass. 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 ofthe 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 onlinegaming. Each user will run the client version of the application on his or her localcomputer. In the game, each user controls two groups of soldiers, Group1 andGroup2.You create a top-level menu item whose caption is Groups. Under this menu, youcreate 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 userselect the Groups menu, the two submenus will be displayed. The user can selectonly one group of soldiers at a time.You must ensure that a group can be selected either by clicking the appropriatesubmenu item or by holding down the ALT key and pressing 1 or 2. You must alsoensure that the group currently select will be indicated by a dot next to thecorresponding submenu item. You do not want to change the caption text of any ofyour menu items.Which four actions should you take? (Each correct answer presents part of thesolution. 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, GExplanation: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 themenu item is selected. We should set the clicked Submenu Checked property to True, andthe other Submenu Checked property to False.G: The menu item's RadioCheck property customizes the appearance of the selectedReference:Visual Basic and Visual C# Concepts, Adding Menu Enhancements to Windows FormsVisual Basic and Visual C# Concepts, Introduction to the Windows Forms MainMenuComponentIncorrect AnswersA: 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 DataSetobject to maintain a working set of data for your users. Users frequently changeinformation in the DataSet object. Before you update your database, you must rundata validation code on all user changes.You need to identify the data rows that contain changes. First you create aDataView 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: DCorrect answer is "Set the RowStateFilter property toModifiedCurrent", this will shows changed rows and the current values.# QUES:You develop a Windows-based orderentry application Abc App. Theapplication uses a DataSet object named customerDataSet to manage client datawhile users edit and update customer records. The DataSet object contains aDataTable object named creditAuthorizationDataTable. This object contains a fieldnamed MaxCredit, which specifies the credit limit for each customer.Customer credit limits cannot exceed $20,000. Therefore, Abc App must verifythat users do not enter a larger amount in MaxCredit. If a user does so, the usermust be notified, and the error must be corrected, before any changes are storedpermanently in the database.You create a procedure named OnRowChanged. This procedure sets theDataTable.Row.RowError property for each row that includes an incorrect creditlimit. You also enable the appropriate event handling so OnRowChanged is called inreaction to the RowChanged event of the DataTable object. OnRowChanged willrun 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 rowsthat are marked as having an error. Which code segment should you use?A. foreach (DataRow myRow increditAuthorizationDataTable.GetErrors()) {MessageBox.Show(String.Format("CustID = {0}, Error = {1}",MyRow["CustID"] . myRow.RowError) ) ;}B. foreach (DataRow myRow increditAuthorizationDataTable.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: AExplanation: GetErrors method gets an array of DataRow objects that containerrors. We use the GetErrors method to get retrieve all rows that contain errors.Reference: .NET Framework Class Library, DataRow.RowError Property [C#]Incorrect AnswersB: The HasErrors property is used to determine if a DataRow contains errors. It returns aBoolean 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 containerrors.# QUES:You develop a Windows-based application Abc App that includes severalmenus. Every top-level menu contains several menu items, and certain menuscontain items that are mutually exclusive. You decide to distinguish the single mostimportant 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: AExplanation: Gets or sets a value indicating whether the menu item is the defaultmenu item. The default menu item for a menu is boldfaced.Reference: .NET Framework Class Library, MenuItem.DefaultItem Property [C#]Incorrect AnswersB: The Text property contains the text that is associated with the control. We cannotformat 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 themenu 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 toedit personal information such as address and telephone number. The form containsa text box named textPhoneNumber.If a user enters an invalid telephone number, the form must notify the user of theerror. You create a function named IsValidPhone that validates the telephonenumber entered. You include an ErrorProvider control named ErrorProvider1 inyour 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: AExplanation: The Validating event allows you to perform sophisticated validationon controls. It is possible to use an event handler that doesn't allow the focus toleave the control until a value has been entered.The ErrorProvider component provides an easy way to communicate validation errors tousers. The SetError method of the ErrorProvider class sets the error description string forthe specified control.Note: Focus events occur in the following order:1. Enter2. GotFocus3. Leave4. Validating5. Validated6. LostFocusReference: 70-306/70-316 Training kit, To create a validation handler that uses theErrorProvider component, Pages 93-94.NET Framework Class Library, ErrorProvider.SetError Method [C#]Incorrect AnswersC: The GetError method returns the current error description string for the specifiedcontrol.E: The updateBinding method provides a method to update the bindings of theDataSource, DataMember, and the error text. However, we just want to set the errordescription.B, D, F: The validated event occurs when the control is finished validating. It can used toperform any actions based upon the validated input.# QUES:You work as a software developer at Abc .com. You develop a Windows-basedapplication that includes two objects named Abc Contact andAbc Employee. Abc Employee inherits from Abc Contact, andAbc Contact exposes an event named DataSaved. You want to raise theDataSaved event from Abc Employee.What should you do?A. Call the RaiseEvent method from Abc Employee and pass DataSaved as the eventname.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 explicitlyraises the DataSaved event.Call RaiseDataSaved from Abc Employee.D. In Abc Employee, create a protected method named RaiseDataSaved thatexplicitly 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. Theapplication includes several menu controls that provide access to most of theapplication's functionality.One menu option is named calculateOption. When a user chooses this option, theapplication will perform a series of calculations based on information previouslyentered by the user.To provide user assistance, you create a TextBox control named Abc Help. Thecorresponding text box must display help information when the user pauses on themenu 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 theIn which event should you add this code segment?A. calculateOption_ClickB. calculateOption_PopupC. calculateOption_SelectD. calculateOption_DrawItemE. calculateOption_MeasureItemAnswer: CExplanation: The Select event is raised when a menu item is highlighted. We shoulduse the Select event to set the helper text.Reference: 70-306/70-316 Training kit, Using Menu Item Events, Page 79Incorrect AnswersA: 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. Itcan 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 performdrawing 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 itembefore drawing it.# QUES:You develop a Windows-based application that will retrieve Abc employeevacation data and display it in a DataGrid control. The data is managed locally in aDataSet 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. Theapplication retrieves a list of contacts from a central database. The list is managedlocally in a DataSet object named listDataSet, and it is displayed in a DataGridcontrol.You create a procedure that will conduct a search after you enter a combination ofpersonal name and family name. You application currently includes the followingcode 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 familyname 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: AExplanation: We load the search parameters into an array. We use two separatevalues. The first value is the FamilyName and the second is PersonalName as it isused 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 306Incorrect AnswersB, D: There are two columns. We must separate the Family name and the Personal intotwo separate strings.C: Wrong order of the search parameters. The family name Bill must be the first searchparameter.
# QUES:You use Visual Studio .NET to create a Windows-based application. On the mainapplication form, Abc FormMain, you create a TextBox control namedtextConnectionString. Users can enter a database connection string in this box toaccess customized data from any database in your company.You also create a Help file to assist users in creating connection strings. The Helpfile will reside on your company intranet.Your application must load the Help file in a new browser window when the userpresses F1 key, but only of textConnectionString has focus. You must create thisfunctionality by using the minimum amount of code.In which event should you write the code to display the Help file?A. textConnectionString_KeyPressB. textConnectionString_KeyDownC. textConnectionString_KeyUpD. textConnectionString_GiveFeedbackE. textConnectionString.HelpReabctedAnswer: EExplanation: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 oran associated context-sensitive help button is clicked. This would be the moststraightforward solution and would require minimal code.Note: Key events occur in the following order:1. KeyDown2. KeyPress3. KeyUpReference:.NET Framework Class Library, Control.HelpReabcted Event [C#].NET Framework Class Library, Control.KeyDown Event [C#]Incorrect AnswersA: The KeyPress event occurs when a key is pressed while the control has focus. TheKeyPress 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 applicationcaptures screen shots of a small portion of the visible screen.You create a form named Abc CameraForm. You set theAbc CameraForm.BackColor property to Blue. You create a button on theform to enable users to take a screen shot.Now, you need to create a transparent portion of Abc CameraForm to frame asmall portion of the screen. Your application will capture an image of the screeninside the transparent area. The resulting appearance of Xyz i ngCameraForm isshown 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 thesolution. 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, FExplanation: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 isBlue.
# QUES:You work as software developer at Abc inc. You need to develop a Windowsform that provides online help for users. You want the help functionality to beavailable when users press the F1 key. Help text will be displayed in a pop-upwindow for the text box that has focus.To implement this functionality, you need to call a method of the HelpProvidercontrol and pass the text box and the help text.What should you do?A. SetShowHelpB. SetHelpStringC. SetHelpKeywordD. ToStringAnswer: BExplanation:To associate a specific Help string with another control, use the SetHelpStringmethod. The string that you associate with a control using this method is displayedin 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 FormsHelpProvider Component# QUES:You develop a Windows-based application. Its users will view and edit employeeattendance data. The application uses a DataSet object named customerDataSet tomaintain the data while users are working with it.After a user edits data, business rule validation must be performed by a middle-tiercomponent named Xyz Component. You must ensure that your application sendsonly 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. Yourapplication will display customer order information from a Microsoft SQL Serverdatabase. The orders will be displayed on a Windows Form that includes aDataGrid control named Abc Grid1. Abc Grid1 is bound to a DataViewobject. Users will be able to edit order information directly in Abc Grid1.You must give users the option of displaying only edited customer orders andupdated values in Abc Grid1.What should you do?A. Set the RowStateFilter property of the DataView object toDataViewRowState.ModifiedOriginal.B. Set the RowStateFilter property of the DataView object toDataViewRowState.ModifiedCurrent.C. Set the RowFilter property of the DataView object toDataViewRowState.ModifiedOriginal.D. Set the RowFilter property of the DataView object toDataViewRowState.ModifiedCurrent.Answer: BExplanation: We must set the RowStateFilter property of the DataView to specifywhich version or versions of data we want to view. We should use theModifiedCurrent. DataViewRowState which provides the modified version oforiginal data.Reference:.NET Framework Class Library, DataViewRowState Enumeration [C#]Incorrect AnswersA, C: The ModifiedOriginal DataViewRowState is used to get the original version of therows 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 aRowStateFilter.# QUES:As a developer at Abc you develop a new salesanalysis application that reusesexisting data access components. One of these components returns a DataSet objectthat contains the data for all customer orders for the previous year.You want your application to display orders for individual product numbers. Userswill 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 filterexpression.Answer: CExplanation: You filter data by setting the RowFilter property. The RowFilterproperty takes a String that can evaluate to an expression to be used for selectingrecords. RowFilter is a property of the DataView object.Reference: Visual Basic and Visual C# Concepts, Filtering and Sorting Data Using DataViewsIncorrect AnswersA: 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, andUnchanged.# QUES:You develop a Windows-based application Xyz . Xyz uses a DataSet object thatcontains two DataTable objects. Xyz will display data from two data tables. Onetable contains customer information, which must be displayed in a data-boundListBox control. The other table contains orderinformation, which must bedisplayed 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: DExplanation: You can use a DataRelation to retrieve parent and child rows. Relatedrows are retrieved by calling the GetChildRows or GetParentRow methods of aDataRow.Note: A DataRelation object represents a relationship between two columns of data indifferent tables. The DataRelation objects of a particular DataSet are contained in theRelations property of the DataSet. A DataRelation is created by specifying the name ofthe DataRelation, the parent column, and the child column.Reference: 70-306/70-316 Training kit, Retrieving Related Records, Page 286Incorrect AnswersA: The Merge method is used to merge two DataSet objects that have largely similarschemas. 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, itwould not help in retrieving related records.# QUES:You develop a Windows-based application to manage business contacts. Theapplication 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 cityname into a TextBox control.The list of contacts that match this name must then be displayed in a DataGridcontrol.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: BExplanation: To form a RowFilter value, specify the name of a column followed byan operator and a value to filter on. The value must be in quotes. Here we useconstruct the rowfilter with the = operator, string concatenation (&) and theTextBox1.Text property.Reference: .NET Framework Class Library, DataView.RowFilter Property [C#]Incorrect AnswersA: 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 interactswith a Microsoft SQL Server database. Your application contains a form namedCustomerForm. 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 theappropriate column in the DataTable object of Abc DataSet. When you test theapplication, you can successfully connect to the database. However, no data isdisplayed in any text boxes.You need to modify your application code to ensure that data is displayedappropriately. Which behavior should occur while the CustomerForm.Load eventhandler is running?A. Execute the Add method of the TextBoxes DataBindings collection and pass inAbc 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 inAbc DataSet.E. Execute the Fill method of Abc DataAdapter and pass in Abc DataSet.Answer: EExplanation: Dataset is a container; therefore, you need to fill it with data. You canpopulate 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. Youadd a custom control named BarGraph, which displays numerical data. You createa second custom control named DataBar. Each instance of DataBar represents onedata value in BarGraph.BarGraph retrieves its data from a Microsoft SQL Server database. For each datavalue that it retrieves, a new instance of DataBar is added to BarGraph. BarGraphalso includes a Label control named DataBarCount, which displays the number ofDataBar controls currently contained by BarGraph.You must add code to one of your custom controls to ensure that DataBarCount isalways updated with the correct value.What are two possible ways to achieve this goal? (Each correct answer presents acomplete 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, EExplanation: We could either catch the ControlAdded event, or add code theconstructor.C: The Control.ControlAdded Event occurs when a new control is added to theControl.ControlCollection. When a control is added to BarGraph we could set the countof 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 AnswersA, 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 thefollowing design-time controls:1. SQLConnection object named Abc Connection2. SQLDataAdapter object named Abc DataAdapter3. DataSet object named CustomerDataSet4. Five TextBox controls to hold the values exposed by CustomerDataSet5. Button control named saveButtonAt design time you set the DataBindings properties of each TextBox control to theappropriate column in the DataTable object of CustomerDataSet.When the application runs, users must be able to edit the information displayed inthe text boxes. All user changes must be saved to the appropriate database whensaveButton is executed. The event handler for saveButton includes the followingcode segment:Abc DataAdapter.Update(CustomerDataSet);You test the application. However, saveButton fails to save any values edited in thetext 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 inAbc Connection.C. Before calling the Update method, ensure that a row position change occurs inCustomerDataSet.D. Reestablish the database connection by calling the Open method ofAbc Connection.Answer: CExplanation: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 anaccounting application, which contains a substantial amount of code. Sometimes adeveloper cannot complete a portion of code until dependencies are completed byanother developer. In these cases, the developer adds a comment in the applicationcode about the work left incomplete. Such comments always begin with theUNDONE.You open the application code on your computer. As quickly as possible, you needto 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 theentire solution.C. Open a code window and use the Find in Files dialog box to search the applicationcode for UNDONE.D. Open a code window and use the Find dialog box to search all open documents forUNDONE.Answer: AExplanation: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 exposesa method named GetCurrentRate. Abc 3 uses GetCurrentRate to obtain thecurrent mortgage interest rate.Six months after you deploy Abc 3, users begin reporting errors. You discoverthat MortgageRate has been modified. GetCurrentRate now requires you to pass apostal code before returning the current mortgage interest rate.You must ensure that Abc 3 consumes the most recent version ofMortgageRate. 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 inAbc 3.D. Use the Add Reference dialog box to recreate the reference to MortgageRate inAbc 3.E. Remove the reference to MortgageRate in Abc 3. Use the Add Web Referencedialog box to create the reference.Answer: CExplanation: If your application contains a Web reference to an XML Web servicethat has been recently modified on the server, you may need to update the referencein your project.To update a project Web reference1. In Solution Explorer, access your project's Web References folder and select the nodefor 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, thatwill be used by other applications, including a standard COM client application.You must deploy your assembly on the COM application to a client computer. Youmust ensure that the COM application can instantiate components within theassembly 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: BExplanation: The Assembly Registration tool reads the metadata within an assembly andadds the necessary entries to the registry, which allows COM clients to create .NETFramework classes transparently. Once a class is registered, any COM client can use it asthough 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 AnswersA: The Strong Name tool helps sign assemblies with strong names.C: The Type Library Importer, tlbimp.exe, converts the type definitions found within aCOM type library into equivalent definitions in a common language runtime assembly. Itwould 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 accountingapplication, which contains a class named Abc Accounts. This class instantiatesseveral classes from a COM component that was created by using Visual Basic 6.0.Each COM component class includes a custom method named ShutDownObjectthat must be called before terminating references to the class.Software testers report that the COM component appears to remain in memoryafter the application terminates. You must ensure that the ShutDownObject methodof 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 ShutDownObjectmethod of each COM component class.B. Find each location in your code where a reference to Abc Accounts is set to nullor goes out of scope.Add code after each instance to manually invoke the Visual Studio .NET garbagecollector.C. Add a destructor to Abc Accounts.Add code to the destructor to call the ShutDownObject method of each COM componentclass.D. Add the procedure private void Finally() to Abc Accounts.Add code to the procedure to call the ShutDownObject method of each COM componentclass.Answer: CExplanation: Be creating a destructor for Abc Accounts class we can ensurethat 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 theAbc company. The application consists of a user interface and several XMLWeb services. You develop all XML Web services and perform unit testing. Nowyou are ready to write the user interface code.Because some of your servers are being upgraded, the XML Web service thatprovides mortgage rates is currently offline. However, you have access to itsdescription 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 localdevelopment computer.D. Add the description file for the XML Web service to your Visual Studio .NET project.Answer: BExplanation:Ordinarily to access an XML Web service from a client application, you first add a Webreference, which is a reference to an XML Web service. When you create a Webreference, Visual Studio creates an XML Web service proxy class automatically and addsit to your project.However, you can manually generate a proxy class using the XML Web servicesDescription Language Tool, Wsdl.exe, used by Visual Studio to create a proxy classwhen adding a Web reference. This is necessary when you are unable to access the XMLWeb service from the machine on which Visual Studio is installed, such as when theXML Web service is located on a network that will not be accessible to the client untilrun time. You then manually add the file that the tool generated to your applicationproject.Reference:Visual Basic and Visual C# Concepts, Locating XML Web ServicesVisual Basic and Visual C# Concepts, Generating an XML Web Service Proxy
# QUES:You use Visual Studio .NET to create an application. Your application contains twoclasses, Region and City, which are defined in the following code segment. (Linenumbers 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 theCalculate 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 resourcesdepartment 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 actualemployees in your company should be represented by interfaces that are derivedfrom IEmployee.Now you need to create a class named Manager to represent executives in yourcompany. 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 thatapply)A. public class Manager:IExecutiveB. public class Manager:IEmployee, IExecutiveC. public class Manager:IEmployeeD. public class Manager:IExecutive, IEmployeeE. public double Salary()F. public double AnnualBonus()Answer: A, E, FA: A class can implement an Interface. The Manager class should implement theIExecutive interface.E, F: The properties that are defined in the Interface must be implemented in a Class.Incorrect AnswersB: 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 definesbusiness rules and performs calculations based on those rules. Other developers inyour company must not be able to override the functions and subroutines defined inXyz BusinessRules with their own definitions.Which two actions should you take to create BusinessRules? (Each correct answerpresents 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 BusinessRulesE. Use the following code segment to define BusinessRules:public new class Xyz BusinessRulesF. Use the following code segment to define BusinessRules:public sealed class Xyz BusinessRulesG. Use the following code segment to define BusinessRules:public abstract class Xyz BusinessRulesAnswer: B, FExplanation:B: You can use the Class Library template to quickly create reusable classes andcomponents 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 theclass.Reference:Visual Basic and Visual C# Concepts, Class Library TemplateC# Programmer's Reference, sealed70-306/70-316 Training kit, Creating Classes That Cannot Be Inherited, Page 182Incorrect AnswersA: The Windows Control Library project template is used to create custom controls touse on Windows Forms.C: When you create a service, you can use a Visual Studio .NET project template calledWindows Service. However, we want to implement Business rules, not network services.D: A protected class will hide properties from external classes and thus keep thisfunctionality 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'teven create class with that syntax, so it surely dont let the developers to inherit from (norto override it's members).G: The abstract modifier is used to indicate that a class is incomplete and that it isintended to be used only as a base class.# QUES:You use Visual Studio .NET to create a Windows-based application that will trackAbc sales. The application's main object is named Abc . The Abc class iscreated by the following definition:public class Abc {}You write code that sets properties for the Abc class. This code must beexecuted 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 codesegment 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: AExplanation: We must create a constructor for the class. We wrote a method whosename is the same as the name of the class, and we specify not return type, not evenvoid.Reference: Visual C# Step by step, page 144Incorrect AnswersB, C: We cannot specify any return type, not even void, when we define a constructor fora 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 ofMicrosoft Windows XP Professional distributed in France. These files containfinancial transaction information, including dates, times, and monetary values. Thedata is stored in a culture-specific format.You develop an application Abc Interactive, which uses these data files. Youmust ensure that Abc Interactive correctly interprets all the data, regardless ofthe 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: CExplanation: The CultureInfo represents information about a specific cultureincluding the names of the culture, the writing system, and the calendar used, aswell as access to culture-specific objects that provide methods for commonoperations, such as formatting dates and sorting strings.Reference: 70-306/70-316 Training kit, Getting and Setting the Current Culture, Pages403-404.NET Framework Class Library, CultureInfo Class [C#]Incorrect AnswersA: We must use the System.Globalization namespace, not the System.Data namespaceB, 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 namedAbc Component. Your application uses namespaces exposed byAbc Component.You must deploy both Abc Client and Abc Component to severalcomputers in your company's accounting department. You must also ensure thatAbc Component can be used by future client applications.What are three possible ways to achieve your goal? (Each correct answer presents acomplete solution. Choose three)A. Deploy Abc Client and Abc Component to a single folder on each clientcomputer.Each time a new client application is developed, place the new application in its ownfolder and copy Abc Component to the new folder.B. Deploy Abc Client and Abc Component to a single folder on each clientcomputer.Each time a new client application is developed, place the new application in its ownfolder.Edit Abc Client.exe.config and add a privatePath tag that points to the folder whereAbc Component is located.C. Deploy Abc Client and Abc Component to separate folders on each clientcomputer.In each client application that will use Abc Component, add the following codesegment: using Abc Component;D. Deploy Abc Client and Abc Component to separate folders on each clientcomputer.Each time a new client application is developed, select Add Reference from the Toolsmenu and add a reference to Abc Component.E. Deploy Abc Client and Jack CBill Component to separate folders on each clientcomputer.Register Abc Component on each client computer by using the RegSvr32 utility.F. Deploy Abc Client and Abc Component to separate folders on each clientcomputer.Add Abc Component to the global assembly cache.Answer: A, B, FExplanation:A: XCOPY deployment of the Abc Component, we simply copy the component tothe 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 intothe 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 GlobalAssembly CacheC# Programmer's Reference, using DirectiveIncorrect AnswersC: 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 (FileNotFoundexception).E: RegSrv32 was used in before the introduction of Visual Studio .NET to register .dllfile. 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. Userinterface elements on the form need to conform to this alignment.You must ensure that all user interface elements are properly formatted when thelocalized Windows Form runs. You must also ensure that Abc Local is easy toupdate 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: BExplanation: The RightToLeft property is used for international applications wherethe language is written from right to leftReference:Visual Basic and Visual C# Concepts, Displaying Right-to-Left Text in Windows Formsfor GlobalizationIncorrect AnswersA: The RightToLeft property can be set either to controls or to the form. The bestsolution 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 yourWindows-based application. The form contains a command button namedcheck Abc Button. When check Abc Button is clicked, the application mustcall a procedure named Get Abc .Which two actions should you take? (Each correct answer presents part of thesolution. Choose two)A. Add arguments to the Get Abc declaration to accept System.Object andSystem.EventArgs.B. Add arguments to the check Abc Button_Click declaration to acceptSystem.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.ClickE. Add the following code segment at the end of the check Abc Button_Clickprocedure:Handles Get AbcAnswer: B, D# QUES:You develop an inventory management application for Abc . The applicationuses a SqlDataReader object to retrieve a product code list from a database. The listis displayed in a drop-down list box on a Windows Form.The Form_Load procedure contains the following code. (Line numbers are includedfor reference only)01 public void ReadMyData (String ConnectionString)02 {03 String query =04 "SELECT CatID, CatName FROM Abc Categories";05 SqlConnection cnn = new06 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 insertadditional code on line 10. Your insertion must minimize the use of database server resources withoutadversely 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 AbcInc. The application enables users to update customer information that is stored in adatabase.Your application contains several text boxes. All TextBox controls are validated assoon as focus is transferred to another control. However, your validation code doesnot function as expected. To debug the application, you place the following line ofcode in the Enter event handler for the first text box:You repeat the process for the Leave, Validated, Validating, and TextChangedevents. In each event, the text is displayed in the output window contains the nameof the event being handled.You run the application and enter a value in the first TextBox control. Then youchange 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 ValidatedB. Enter TextChanged Leave Validating ValidatedC. Enter Validating Validated TextChanged LeaveD. Enter TextChanged Validating Validated LeaveE. Enter Validating TextChanged Validated LeaveAnswer: B# QUES:You create the user interface for a Windows-based application. The main form inyour application includes an Exit menu item named exitItem and an Exit buttonnamed 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 exitcode. }Answer: A# QUES:You use Visual Studio .NET to create a component named Reabct. This componentincludes a method named AcceptCKReabct, which tries to process new userreabcts for services. AcceptCKReabct calls a private function named Validate.You must ensure that any exceptions encountered by Validate are bubbled up to theparent form of Reabct. The parent form will then be responsible for handling theexceptions. You want to accomplish this goal by writing the minimum amount ofcode.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: AExplanation: The unhandled exception automatically will be thrown to the clientapplication. This solution meets the requirement that the least amount of codeshould be used.Not B: Options A and B produce the same result. Option A is better solution because ofminimized coding. Catching and just throwing an exception in the catch block, withoutany additional processing is meaningless.# QUES:You use Visual Studio .NET to create a Windows-based application. The applicationincludes a form named Abc . You implement print functionality in Abc byusing the native .NET System Class Libraries.Abc will print a packing list on tractor-fed preprinted forms. The packing listalways consists of two pages. The bottom margin of page 2 is different from thebottom 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 theQueryPageSettingEventArgs 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: BExplanation:It is possible to print each page of a document using different page settings. You set pagesettings by modifying individual properties of theQueryPageSettingsEventArgs.PageSettings property. Changes made to the PageSettingsaffect 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 tospecify 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 AnswersA: 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 applicationincludes a form named Abc Procedures (CKP). CKP allows users to enter verylengthy text into a database. When users click the Print button located on CKP, thistext must be printed by the default printer. You implement the printingfunctionality by using the native .NET System Class Libraries with all defaultsettings.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 objectto True.B. In the EndPrint event, set the HasMorePages property of the PrintEventArgs object toTrue.C. In the PrintPage event, set the HasMorePages property of the PrintPageEventArgsobject to True.D. In the QueryPageSettings event, set the HasMorePages property of theQueryPageSettingEventArgs object to True.Answer: CExplanation: PrintDocument.PrintPage Event occurs when the output to print forthe current page is needed. This event has the HasMorePages property which getsor 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 isdefined 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 theContactSaved event raised by the Contact object. The Contact object will beinitialized 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: CExplanation: 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 yourdesired 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-144Incorrect AnswersA: 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 mustbe used:new EventHandler(HandleContactSaved)
# QUES:You are a developer for a Abc Inc that provides free software over theInternet. You are developing en e-mail application that users all over the world candownload.The application displays text strings in the user interface. At run time, these textstrings must appear in the language that is appropriate to the locale setting of thecomputer running the application.You have resources to develop versions of the application for only four differentcultures. You must ensure that your application will also be usable by people ofother 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: CExplanation: When you build a project, the resource files are compiled and thenembedded in satellite assemblies, or assemblies which contain only the localizedresources. The fallback resources are built into the main assembly, which alsocontains the application code.Reference:Visual Basic and Visual C# Concepts, What's New in International ApplicationsVisual Basic and Visual C# Concepts, Introduction to International Applications inVisual Basic and Visual C#Incorrect AnswersA: 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. Theapplication includes a COM component that you created.Abc .com company policy requires you to sign the Abc Op assembly with astrong name. However, issues of company security require that you delay signingthe assembly for one month. You need to begin using the application immediately ona 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 theSystem.Runtime. Abc OpServices namespace.D. Create a custom wrapper by creating a duplicate definition or interface of the class inmanaged source code.Answer: BExplanation: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 acommon class library assembly named Abc Customers. You deploy theapplication to client computers on your company intranet.Later, you modify Abc Customers.Any application that uses version 1.0.0.0must 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: CExplanation: When an assembly vendor releases a new version of an assembly, thevendor can include a publisher policy so applications that use the old version nowuse the new version.Reference:.NET Framework General Reference, Element# QUES:Your company uses Visual Studio .NET to create a Windows-based application forAbc . The application is named CustomerTracker, and it calls an assemblynamed Schedule.Six months pass. The hospital asks your company to develop a new Windows-basedapplication. The new application will be named EmployeeTracker, and it will alsocall Schedule. Because you anticipate future revisions to this assembly, you wantonly one copy of Schedule to serve both applications.Before you can use Schedule in EmployeeTracker, you need to complete somepreliminary tasks.Which three actions should you take? (Each correct answer presents part of thesolution. 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, EExplanation: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 theglobal 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 GlobalAssembly Cache.NET Framework Developer's Guide, Side-by-Side ExecutionIncorrect AnswersB: Side-by-side execution is the ability to run multiple versions of the same assemblysimultaneously. It is not required in this scenario.D: The assembly should be moved to the global assembly cache, not to theWindows\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 otherVisual Studio .NET applications. No Permissions should be granted to this assemblyunless the assembly makes a minimum permission reabct for them.Which code segment should you use?A. B. C. D. Answer: DExplanation: The ReabctOptional SecurityAction reabcts for additionalpermissions that are optional (not required to run). This action can only be usedwithin the scope of the assembly. The code needs only the minimum set ofpermissions and no others. It should not be granted any optional permissions that ithas not specifically reabcted. We must therefore use Unrestricted := False.Reference:.NET Framework Developer's Guide, Reabcting Optional PermissionsIncorrect Answers:A, B: The PermitOnlySecurityAction does not support Assembly as a target, it only supports Class or Methodas targets.C: The assembly must only be granted minimal permissions. It should not be granted anyoptional 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 namedsp_UpdatePrices.sp_UpdateCKPrices performs a SQL UPDATE statement that increases prices forselected 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 andreturns the results to a SqlDataReader object. The SqlDataReader object gives youaccess to the data in the result set. Which is displayed in a list box on your WindowsForm.The value of @totalprice must also be displayed in a text box on your WindowsForm. 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.closeC.TextBox1.Text=com.parameters["@totalprice"].value.ToString(); reader.close(); D.reader.close();TextBox1.Text= com.parameters["@totalprice"].value.ToString(); A.cmd.executeNonQuery();Answer:DExplanation: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. Theassembly will reside on the client computer when the application is installed. Youmust ensure that any future applications installed on the same computer can accessthe assembly.Which two actions should you take? (Each correct answer presents part of thesolution. 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, FExplanation:The global assembly cache stores assemblies specifically designated to be shared byseveral 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 deploymentproject.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 GlobalAssembly Cache.NET Framework Developer's Guide, Installing an Assembly into the Global AssemblyCache# QUES:You use Visual Studio .NET to create a control that will be used on several forms inyour application. It is a custom label control that retrieves and displays yourcompany's current stock price.The control will be displayed on many forms that have different backgrounds. Youwant the control to show as much of the underlying form as possible. You want toensure that only the stock price is visible. The rectangular control itself should notbe 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 thesolution. Choose two)A. ContextMenu1.MenuItems.Clear();B. ContextMenu1.MenuItems.Add("&Display Help");C. ContextMenu1.MenuItems.Add(helpCKOption.CloneMenu();D. ContextMenu1.MenuItems[0].Click += newSystem.EventHandler(helpCKOption_Click)E. this.SetStyle(ControlStyles.SupportsTransparentBackColor,true )Answer: A, EExplanation: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 yourcontrol's BackColor to Transparent. :this.Backcolor=color.Transparent; Reference: Visual Basic and Visual C# Concepts, Giving YourControl aTransparentBackground# QUES.You are developing a Windows-based application that logs hours worked byAbc employees. Your design goals require you to maximize applicationperformance and minimize impact on server resources.You need to implement a SqlCommand object that will send a SQL INSERT actionquery to a database each time a user makes a new entry.To create a function named LineItemInsert, you write the following code. (Linenumbers 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;0607 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);1314 // Insert new code.15 }You code must execute the SQL INSERT action query and verify the number of database records thatare 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 aMicrosoft SQL Server stored procedure named Abc EmployeeData. Thisprocedure accepts a parameter for querying the database by an employee's familyname.You need to add code to your application to set up the parameter for use with thestored procedure.Which three lines of code should you add? (Each correct answer presents part of thesolution. 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 Serverdatabase. The application includes a form named CustomerForm, which contains aButton control named SortButton. The database includes a table named Customers.Data from Customers will be displayed on CustomerForm by means of a DataGridcontrol 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 ensurethat the data will be displayed in ascending orderby primary key when the userselects 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 DataAdapter object.D. Set the RowFilter property of the DataView object to CustomerID.Answer: AExplanation: The data view definition includes the follow command:dv.sort = "city ASC,contactName ASC"; This enforces sorting on the City and the ContactNamecolumns. Itoverrides the defaultsort order. We must set the Sort property to an empty string. This would enable thedefault sort order.Reference: Visual Basic and Visual C# Concepts, Filtering and Sorting Data Using DataViewsIncorrect AnswersB: By default a view is sorted on the Primary Key in ascending order. We would to setthe 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 calledAbc App. Your application will display customer orderinformation from aMicrosoft SQL Server database. The orders will be displayed on a Windows Formin a data grid named DataGrid1. DataGrid1 is bound to a DataView object.The Windows Form includes a button control named displayBackOrder. Whenusers click this button, DataGrid1 must display only customer orders whoseBackOrder 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: AExplanation: Using the RowFilter property of a data view, you can filter records ina 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 DatasetsVisual Basic and Visual C# Concepts, Filtering and Sorting Data Using Data ViewsIncorrect AnswersB: To filter based on a version or state of a record, set the RowStateFilter property. Itdoes 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 interactswith a Microsoft SQL Server database. Your application contains a form namedCustomerForm, 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 namedCustomers.At run time you add a TextBox control named textCompanyName toCustomerForm. You execute the Fill method of Abc DataAdapter to populateCustomers. Now you want to use data binding to display the CompanyName fieldexposed 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