Practice Exam

Question 1

You are developing an accounting application that includes a class named Transaction , which is inherited by subclasses such as DepositTransaction and PaymentTransaction . The Transaction class includes a method named VerifyChecksum() . The VerifyChecksum() method should be available to the Transaction class and to all classes derived from the Transaction class, but not to any other classes in the application. Which access modifier should you use in the declaration of the VerifyChecksum() method?

  • A. protected

  • B. public

  • C. private

  • D. internal

Question 2

You have developed an ASP.NET page that contains the following code:

 <%@ Page Language="c#" AutoEventWireUp="true"          EnableViewState="true" SmartNavigation="false"%> <html>     <script runat="server">         protected void Page_Load(Object o, EventArgs e)         {             if(!Page.IsPostBack)             {                 // Populate the color drop-down list                 ddlColor.Items.Add("Blue");                 ddlColor.Items.Add("Red");                 ddlColor.Items.Add("Green");             }         }         protected override void OnInit(EventArgs e)         {             this.Load += new EventHandler(Page_Load);             base.OnInit(e);         }     </script>     <body>         <form runat="server">              Select a Color:                <asp:DropDownList id="ddlColor"                                  runat="server" >                <asp:Button id="btnSubmit"runat="server" >         </form>     </body> </html> 

When you view the page in the browser, you find that the color names are displayed twice in the drop-down list. Which of the following options should you choose to solve this problem?

  • A. Modify the Page directive as follows :

     <%@ Page Language="c#"          AutoEventWireUp="true"          EnableViewState="false"          SmartNavigation="false"%> 
  • B. Modify the Page directive as follows:

     <%@ Page Language="c#"          AutoEventWireUp="true"          EnableViewState="true"          SmartNavigation="true"%> 
  • C. Modify the Page directive as follows:

     <%@ Page Language="c#"          AutoEventWireUp="false"          EnableViewState="true"          SmartNavigation="false"%> 
  • D. Modify the Page_Load() method as follows:

     protected void Page_Load(Object o, EventArgs e) {    if(Page.IsPostBack)    {        // Populate the color drop-down list        ddlColor.Items.Add("Blue");        ddlColor.Items.Add("Red");        ddlColor.Items.Add("Green");    } } 
Question 3

You are designing a Visual C# ASP.NET Web form with a variety of controls on its user interface. Some controls will be infrequently used. For these controls, you do not want the user to be able to tab into the control, but the user should still be able to activate the control by clicking in it. Which of the following options should you use?

  • A. Set the TabIndex property of the control to .

  • B. Set the TabIndex property of the control to -1 .

  • C. Set the AccessKey property of the control to null .

  • D. Set the Enabled property of the control to false .

Question 4

You have developed a Web page that uses the Image ASP.NET Web server control to display images from various sources on the Internet. Sometimes an image might not be available because a Web site might be temporarily down for maintenance. In these situations, you are required to display a description for the image. Which of the following properties of Image would you use?

  • A. ToolTip

  • B. Attributes

  • C. AlternateText

  • D. ImageUrl

Question 5

You are designing a Web site that is used by your suppliers to quote their pricing for a product that your company will buy over the next quarter. The Web site will use data to calculate the best possible purchase options. Your application displays three text boxes to the suppliers. The first text box ( txtPrevQtrMax ) enables suppliers to enter the maximum value charged by them for this product in the previous quarter. The second text box ( txtPrevQtrMin ) enables suppliers to enter the minimum value charged by them in the previous quarter. The third text box ( txtQuote ) enables suppliers to enter the proposed pricing of the product for the next quarter. You want suppliers to restrict the value of the txtQuote field between txtPrevQtrMin and txtPrevQtrMax . The validation technique you use should utilize the minimum amount of code. Which of the following validation controls would you use to perform the validation?

  • A. CompareValidator

  • B. RangeValidator

  • C. CustomValidator

  • D. RegularExpressionValidator

Question 6

Your ASP.NET application enables users to input the URL of a Web page, and then it applies an XSLT file to show how that Web page looks on a mobile device. Which type of control should you use to validate the TextBox control where the user inputs the URL? (Select two options; each option presents part of the complete answer.)

  • A. RequiredFieldValidator

  • B. RangeValidator

  • C. RegularExpressionValidator

  • D. CompareValidator

Question 7

You are assisting your colleague in solving the compiler error his code is throwing. Following is the problematic portion of his code:

 try {     bool success = GenerateNewtonSeries(500, 0);     //more code here } catch(DivideByZeroException dbze) {     //exception handling code } catch(NotFiniteNumberException nfne) {     //exception handling code } catch(ArithmeticException ae) {     //exception handling code } catch(OverflowException e) {     //exception handling code } 

To remove the compilation error, which of the following ways would you rearrange the code?

  • A.

     try {     bool success = GenerateNewtonSeries(500, 0);     //more code here } catch(DivideByZeroException dbze) {     //exception handling code } catch(ArithmeticException ae) {     //exception handling code } catch(OverflowException e) {     //exception handling code } 
  • B.

     try {     bool success = GenerateNewtonSeries(500, 0);     //more code here } catch(DivideByZeroException dbze) {     //exception handling code } catch(Exception ae) {     //exception handling code } catch(OverflowException e) {     //exception handling code } 
  • C.

     try {     bool success = GenerateNewtonSeries(500, 0);     //more code here } catch(DivideByZeroException dbze) {     //exception handling code } catch(NotFiniteNumberException nfne) {     //exception handling code } catch(OverflowException e) {     //exception handling code } catch(ArithmeticException ae) {     //exception handling code } 
  • D.

     try {     bool success = GenerateNewtonSeries(500, 0);     //more code here } catch(DivideByZeroException dbze) {     //exception handling code } catch(NotFiniteNumberException nfne) {     //exception handling code } catch(Exception ae) {     //exception handling code } catch(ArithmeticException e) {     //exception handling code } 
Question 8

You've developed an ASP.NET Web application that retrieves data from a SQL Server database named Customers. You use the System.Data.SqlClient data provider to connect with the database. You need to log the severity level of the errors returned from the SQL Server .NET data provider. Which of the following options should you choose?

  • A. Catch the SqlException , which is thrown by the SQL Server .NET data provider. Examine the Class property of the SqlException object.

  • B. Catch the SqlException , which is thrown by the SQL Server .NET data provider. Examine the Source property of the SqlException object.

  • C. Catch the SqlException , which is thrown by the SQL Server .NET data provider. Examine the Server property of the SqlException object.

  • D. Catch the SqlException , which is thrown by the SQL Server .NET data provider. Examine the State property of the SqlException object.

Question 9

The machine.config file on your computer contains this setting:

 <customErrors mode="RemoteOnly"/> 

Your application's root directory contains a web.config file with this setting:

 <customErrors mode="On">     <error statusCode="404" redirect="404.htm" /> </customErrors> 

Your application's /custom directory contains a web.config file with this setting:

 <customErrors mode="Off" /> 

Your application's /custom/local directory contains a web.config file with this setting:

 <customErrors mode="On">     <error statusCode="404" redirect="404.aspx" /> </customErrors> 

A user at a remote computer requests the file /custom/remote/NonExistingPage.aspx , which does not exist. What is the result?

  • A. The 404.aspx file is displayed.

  • B. The default ASP.NET error page is displayed.

  • C. The 404.htm file is displayed.

  • D. The stack trace information for the error is displayed.

Question 10

Your ASP.NET application contains a Web form named login.aspx . When this page is posted back to the server, you check the entered username and password against your corporate database. If the username and password match, you want to display the accountdetails.aspx Web form as the result in the user's browser. Execution of the application will proceed from the accountdetails.aspx page. How should you transfer control in this case?

  • A. Use the HyperLink ASP.NET Web server control.

  • B. Use the Response.Redirect() method.

  • C. Use the Server.Transfer() method.

  • D. Use the Server.Execute() method.

Question 11

You are creating an ASP.NET Web application that reads a text file and displays its data in the browser. You set the BufferOutput property of the HttpResponse object to true . You then execute the CreateHeaders.aspx page using the Server.Execute() method to display heading information to the browser. After this, you read the file and display it in the browser. If the file is not found, you want to remove any heading information created for the output and you want the page to continue execution. How can you achieve this?

  • A. Use Response.Flush(); .

  • B. Use Response.Clear(); .

  • C. Use Response.Close(); .

  • D. Use Response.End(); .

Question 12

Your ASP.NET Web form displays ordering information for 50 products in DataGrid and other controls. Your company is unable to accept Web orders, so there are no controls on the page to post the data back to the server. What can you do to optimize the delivery of this page?

  • A. Set the EnableViewState attribute to true for the DataGrid control.

  • B. Set the EnableViewState attribute to true for the Page directive.

  • C. Set the EnableViewState attribute to false for the DataGrid control.

  • D. Set the EnableViewState attribute to false for the Page directive.

Question 13

Your ASP.NET shopping application is deployed and running on a production server. Web site hits have increased recently, so you are planning to deploy the ASP.NET Web application to a Web farm, which consists of four servers handling the requests from users. Which of the following steps should you perform before you move your Web application to a Web farm?

  • A. Disable session state for the application.

  • B. Use either the State Service or SQL Server to store session state.

  • C. Use View state, rather than session, to maintain state.

  • D. Remove all references to the Request, Response , and Server objects from your code.

Question 14

You are in the process of upgrading an existing ASP application to ASP.NET by converting pages one by one to the new architecture. The application currently uses an ASP.NET page to request the user's first name , which is stored in a session variable with this line of code:

 Session["FirstName"] = txtFirstName.Text; 

You run the application and enter a first name on the ASP.NET page. When you browse to an existing ASP page that uses the FirstName session variable, the first name is blank. What could be the problem?

  • A. You must explicitly use the Page.Session property to store shared session state.

  • B. The ASP page needs to explicitly retrieve the Value property of the Session object.

  • C. The ASP and ASP.NET engines do not share session state or application state.

  • D. You do not have cookies enabled on your computer.

Question 15

You are designing an ASP.NET Web application for a multinational company. When users access the Web site, you want them to be automatically redirected to a page specific to their country. Your colleague has developed a method that determines the user's country from the HTTP request and performs the redirection. Where should you call this method in your application?

  • A. In the Session_Start() event handler of the global.asax file

  • B. In the Application_BeginRequest() event handler of the global.asax file

  • C. In the Page_Load() event handler of the default.aspx file

  • D. In the Application_Start() event handler of the global.asax file

Question 16

You have created an ASP.NET Web page, Catalog.aspx , that enables users to purchase products from the catalog. The product details are fetched in a DataSet object from a legacy database over a slow link. The details are displayed in the Catalog.aspx page in a DataGrid control as per user preferences, which are maintained in the session state. The product details do not change very often; you need to reload the DataSet object only every two hours. Which of the following options should you use to store the DataSet object?

  • A. Application state

  • B. Session state

  • C. View state

  • D. The HttpCachePolicy object

  • E. The Cache object

Question 17

You are creating an ASP.NET Web page that performs complex mathematical and scientific calculations and displays the results to the user. The complex calculations use server resources extensively. The calculations change once every 30 minutes. Which of the following OutputCache directives should you choose to enable caching on the Web page?

  • A. <%@ OutputCache Duration="30" VaryByParam="None" %>

  • B. <%@ OutputCache Duration="1800" VaryByParam="None" %>

  • C. <%@ OutputCache Duration="30" %>

  • D. <%@ OutputCache Duration="1800" %>

Question 18

You have developed an ASP.NET Web form that displays information on parks by fetching data from a SQL Server 2000 database. The database contains information on approximately 2,500 parks. The user can select a state from the ddlStates control and select a park from the ddlParks control to get information on the desired park. The page also accepts other information from the user, but this information does not influence the results. Users request these pages very frequently. Which of the following OutputCache directives should you use to maximize performance?

  • A. <%@ OutputCache Duration="120" VaryByParam="*" %>

  • B. <%@ OutputCache Duration="120" VaryByParam="ddlStates;ddlParks" %>

  • C. <%@ OutputCache Duration="120" VaryByParam="ddlParks" %>

  • D. <%@ OutputCache Duration="120" VaryByControl="ddlParks" %>

  • E. <%@ OutputCache Duration="120" VaryByControl="ddlStates;ddlParks" %>

  • F. <%@ OutputCache Duration="120" VaryByControl="*" %>

Question 19

You've developed a Visual C# ASP.NET Web application that displays supplier data in a DataGrid control. The supplier data is stored in a data cache in a table named Suppliers within the dsSuppliers DataSet object. The primary key for the Suppliers table is the SupplierID column. You need to display the supplier data in the DataGrid control in ascending order of the primary key. You write the following code segment to accomplish this task:

 DataView dvSuppliers = new DataView(dsSuppliers.Tables["Suppliers"]); dvSuppliers.Sort = "ASC"; dvSuppliers.ApplyDefaultSort = true; dataGrid1.DataSource = dvSuppliers; dataGrid1.DataBind(); 

However, when you run the program, the results are not as expected. How should you change the previous code segment to get the intended results?

  • 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. Set the RowFilter property of the DataView object to SupplierID .

  • D. The code segment is correct; you need to ensure that the data in the Suppliers table is already sorted on the primary key.

Question 20

Your new project is to write a Visual C# ASP.NET Web application that enables professors to maintain the scores of their students. You place a DataGrid control on the Web form and bind the data grid to a DataView object. You allow professors to make changes in the data grid by adding new rows, modifying existing rows, and deleting existing rows. You now want to insert a command button that enables professors to view the deleted rows from the original data. How should you program the Click event of the command button?

  • A. In the event handler for the Click event, set the RowFilter property of the DataView object to DataViewRowState.Deleted .

  • B. In the event handler for the Click event, set the RowFilter property of the DataView object to DataViewRowState.OriginalRows .

  • C. In the event handler for the Click event, set the RowStateFilter property of the DataView object to DataViewRowState.Deleted .

  • D. In the event handler for the Click event, set the RowStateFilter property of the DataView object to DataViewRowState.OriginalRows .

Question 21

You have created an array of Project objects named aProjects . Each Project object has a Name property and a Number property. You want to display all the Name values in a ListBox Web server control named lbProjects . Which code snippet should you use for this purpose?

  • A.

     lbProjects.DataSource = aProjects; lbProjects.DataValueField = Name; lbProjects.DataBind(); 
  • B.

     lbProjects.DataSource = aProjects; lbProjects.DataTextField = Name; lbProjects.DataBind(); 
  • C.

     lbProjects.DataSource = aProjects; lbProjects.DataValueField = "Name"; lbProjects.DataBind(); 
  • D.

     lbProjects.DataSource = aProjects; lbProjects.DataTextField = "Name"; lbProjects.DataBind(); 
Question 22

You've used Visual Studio .NET to develop an ASP.NET Web application that queries data from a SQL Server database. You used the SqlConnetion object to connect to the database. As soon as the database operation is completed, you want to ensure that any pending database transactions are rolled back and connection is returned to the connection pool. You need to reuse the same SqlConnection object when your program needs to query the database again. Which of the following actions should you take?

  • A. Call the Dispose() method on the SqlConnection object.

  • B. Call the destructor of the SqlConnection object.

  • C. Call the Close() method on the SqlConnection object.

  • D. Set the SqlConnection object to null .

Question 23

You've developed an ASP.NET Web application that enables users to view and modify recently placed orders. Your application needs to display data from the OrderHeader and OrderDetails data tables. Information from OrderHeader is displayed in a ListBox control, whereas information from OrderDetails is displayed in a DataGrid control. Your program must ensure that, as soon as a different order is selected in the ListBox control, the DataGrid control displays the details corresponding to that order. Which of the following actions will you take to implement this functionality?

  • A. Define primary keys on the OrderHeader and OrderDetails tables.

  • B. Create a foreign key constraint in the OrderDetails table.

  • C. Add a DataRelation object to the Relations collection of the DataSet object.

  • D. Use the DataSet.Merge() method.

Question 24

You need to develop an ASP.NET Web application named ProcessOrders . This application receives XML data files from various customers, reads the files, and stores them in a SQL Server database for further processing. The ProcessOrders application uses an XML schema file to define the format and data types of the XML data files. However, not all customers send the XML data file using the same schema. Your application should parse the incoming data files to ensure that they conform to the XML schema. Which of the following actions should you take to accomplish this requirement?

  • A. Implement an XmlDocument object to load the document. Pass the schema file to this object to validate and parse the XML document.

  • B. Implement an XmlValidatingReader object and program an event handler for the ValidationEventHandler event to parse the data file that does not conform to the XML schema.

  • C. Read the XML file into a DataSet object and set its EnforceConstraints property to true .

  • D. Read the XML file and schema into a DataSet object. Program the DataSet.MergeFailed event handler to parse the data file that does not conform to the XML schema.

Question 25

You are developing a Visual C# ASP.NET Web application to query product information from a SQL Server database. The application specification requires that the users of your application be able to search for a product just by entering the first few characters. You store the characters entered by the user in a variable named ProdName . Which of the following SQL statements should you use to retrieve the data from the database?

  • A.

     sqlStatement = "SELECT Name, Description, Price FROM " +    "Product WHERE Name IN '" + ProdName + "%'"; 
  • B.

     sqlStatement = "SELECT Name, Description, Price FROM " +     "Product WHERE Name LIKE '" + ProdName + "%'"; 
  • C.

     sqlStatement = "SELECT Name, Description, Price FROM " +     "Product WHERE Name IN '" + ProdName + "*'"; 
  • D.

     sqlStatement = "SELECT Name, Description, Price FROM " +     "Product WHERE Name LIKE '" + ProdName + "*'"; 
Question 26

Your Visual C# .NET application needs to read data from a SQL Server 6.5 database and write it to a flat file once every 12 hours. A legacy application accesses this file to update its data. Because the data it will read from the database is huge, you want to retrieve the data with very little impact on the server resources while maximizing performance. Which object should you use to load the data from the database?

  • A. DataSet

  • B. DataTable

  • C. SqlDataReader

  • D. OleDbDataReader

Question 27

You allow users to edit product information on a DataGrid control bound to a DataSet object. When a user clicks the Update button on the form, you call the SqlDataAdapter.Update() method to cause the changes from the DataSet object to persist to the underlying database. Users report that new records and updated rows are saved properly but deleted rows reappear the next time they run the application. What could be the problem?

  • A. The users do not have permission to update the underlying table.

  • B. The Update() method does not delete rows.

  • C. Someone is restoring an old version of the database between the two executions of the program.

  • D. You forgot to set the DeleteCommand property of the SqlDataAdapter object.

Question 28

Your ASP.NET Web application has two FileStream objects. The fsIn object is open for reading, and the fsOut object is open for writing. Which code snippet would copy the contents of fsIn to fsOut using a 2KB buffer?

  • A.

     Int32[] buf = new  Int32[2048]; Int32 intBytesRead; while((intBytesRead = fsIn.Read(buf, 0, 2048)) > 0)     fsOut.Write(buf, 0, intBytesRead); fsOut.Flush(); fsOut.Close(); fsIn.Close(); 
  • B.

     Int32[] buf = new  Int32[2048]; Int32 intBytesRead; while((intBytesRead = fsIn.Read(buf, 0, 2048)) > 1)     fsOut.Write(buf, 0, intBytesRead); fsOut.Flush(); fsOut.Close(); fsIn.Close(); 
  • C.

     Byte[] buf = new  Byte[2048]; Int32 intBytesRead; while((intBytesRead = fsIn.Read(buf, 0, 2048)) > 0)     fsOut.Write(buf, 0, intBytesRead); fsOut.Flush(); fsOut.Close(); fsIn.Close(); 
  • D.

     Byte[] buf = new  Byte[2048]; Int32 intBytesRead; while((intBytesRead = fsIn.Read(buf, 0, 2048)) > 1)     fsOut.Write(buf, 0, intBytesRead); fsOut.Flush(); fsOut.Close(); fsIn.Close(); 
Question 29

Your SQL Server database contains a table, Sales , with these columns :

 SalesID (int, identity) StoreNumber (int) Sales (int) 

You have created the following stored procedure that accepts as inputs the store number and sales, inserts a new row in the table with this information, and returns the new identity value:

 CREATE PROCEDURE procInsertSales   @StoreNumber int,   @Sales int,   @SalesID int OUTPUT AS   INSERT INTO Sales (StoreNumber, Sales)   VALUES (@StoreNumber, @Sales)   SELECT @SalesID = @@IDENTITY 

Which statement should you use to define the SqlParameter object for the @SalesID parameter for the previous stored procedure?

  • A.

     SqlParameter paramSalesID = new SqlParameter(      "@SalesID", SqlDbType.Int); paramSalesID.Direction = ParameterDirection.Output; 
  • B.

     SqlParameter paramSalesID = new SqlParameter(      "@SalesID", SqlDbType.Int); paramSalesID.Direction = ParameterDirection.ReturnValue; 
  • C.

     SqlParameter paramSalesID = new SqlParameter(      "@SalesID", Int32); paramSalesID.Direction = ParameterDirection.Output; 
  • D.

     SqlParameter paramSalesID = new SqlParameter(      "@SalesID", Int32); paramSalesID.Direction = ParameterDirection.ReturnValue; 
Question 30

You have defined a method named DataLoad that makes a list of suppliers available by returning an ICollection interface. You have an ASP.NET Web form with a ListBox control named lbCustomers . The Page_Load event handler for the Web form contains this code:

 private void Page_Load(object sender, System.EventArgs e) {     lbCustomers.DataSource = DataLoad();     lbCustomers.DataTextField = "CustomerName"; } 

The Web form opens without error, but no customer names are displayed. What is the problem?

  • A. You have neglected to call the DataBind() method of the page.

  • B. You have neglected to set the DataValueField property of the ListBox control.

  • C. A ListBox control cannot be bound to an ICollection interface.

  • D. The code should be placed in the Page_Init() event handler.

Question 31

You are designing a Web form that will use a Repeater Web server control to display information from several columns of the Orders table in your database. You want to display the column names at the top of the control in Label Web server controls. Which template should you include with the column names?

  • A. ItemTemplate

  • B. AlternatingItemTemplate

  • C. HeaderTemplate

  • D. SeparatorTemplate

Question 32

You are creating a user control that displays employee names whose birthdays fall in the current quarter. The user control is displayed in the activities page of your company's intranet. You have placed a Repeater control in the user control and are using data binding to display values from the dsEmployees DataSet object into the Repeater control. The Repeater control contains the following definition:

 <asp:Repeater id="rptProducts" runat="server"  DataSource="<%# dsEmployees %>" DataMember="Employees"> 

You want to display the employee's name and the month and day of her birthday in the Repeater control. Which of the following options would you choose to maximize performance?

  • A.

     <ItemTemplate>     <tr>         <td><%# DataBinder.Eval(Container. DataItem, "Name") %></td>         <td><%# DataBinder.Eval(          Container.DataItem, "Date", "{0:m}") %></td>     </tr> </ItemTemplate> 
  • B.

     <ItemTemplate>     <tr>         <td><%# DataBinder.Eval(Container. DataItem, "Name") %></td>         <td><%# DataBinder.Eval(          Container.DataItem, "Date") %></td>     </tr> </ItemTemplate> 
  • C.

     <ItemTemplate>     <tr>         <td><%# ((DataRowView) Container.DataItem) ["Name"] %></td>         <td><%# String.Format("{0:m}",           ((DataRowView) Container.DataItem)["Date"]) %></td>     </tr> </ItemTemplate> 
  • D.

     <ItemTemplate>     <tr>         <td><%# ((DataRowView) Container.DataItem) ["Name"] %></td>         <td><%# ((DataRowView) Container.DataItem) ["Date"]) %></td>     </tr> </ItemTemplate> 
Question 33

You've developed an ASP.NET Web application named ProcessOrder using Visual C# .NET. Your application receives orders from customers in an XML file named Orders.xml , which does not include a schema. Which of the following methods should you use to load data from Orders.xml into a DataSet object? (Select two.)

  • A.

     DataSet ds = new DataSet("Orders"); ds.ReadXml("Orders.xml", XmlReadMode.Auto); 
  • B.

     DataSet ds = new DataSet("Orders"); ds.ReadXml("Orders.xml", XmlReadMode.DiffGram); 
  • C.

     DataSet ds = new DataSet("Orders"); ds.ReadXml("Orders.xml", XmlReadMode.Fragment); 
  • D.

     DataSet ds = new DataSet("Orders"); ds.ReadXml("Orders.xml", XmlReadMode.InferSchema); 
  • E.

     DataSet ds = new DataSet("Orders"); ds.ReadXml("Orders.xml", XmlReadMode.ReadSchema); 
Question 34

You've created an ASP.NET Web Service project using Visual Studio .NET. The project includes a class named RefLibrary , and this class contains the following method:

 public String Version() {     return "1.6"; } 

You note that you are able to instantiate the RefLibrary class from a Web service client project, but the Version() method is not available. What could be the problem?

  • A. Only properties can be part of the public interface of a Web service.

  • B. You must mark the method with the WebService attribute.

  • C. The methods of a Web service can return only object data.

  • D. You must mark the method with the WebMethod attribute.

Question 35

Your ASP.NET application performs various mathematical calculations, and you are beginning to sell this application in multiple countries . How should you ensure that the correct numeric formatting is used in all cases?

  • A. Allow the user to select a culture from a list. Create a CultureInfo object based on the user's selection and assign it to the Thread.CurrentThread.CurrentCulture property. Use the ToString() method to format numeric amounts.

  • B. Retrieve the value of Request.UserLanguages(0) when you're processing the page and assign it to the Thread.CurrentThread. CurrentCulture property. Use the ToString() method to format numeric amounts.

  • C. Allow the user to select a culture from a list. Create a CultureInfo object based on the user's selection and assign it to the Thread. CurrentThread.CurrentUICulture property. Use the ToString() method to format numeric amounts.

  • D. Retrieve the value of Request.UserLanguages(0) when you're processing the page and assign it to the Thread.CurrentThread. CurrentUICulture property. Use the ToString() method to format numeric amounts.

Question 36

Your ASP.NET application needs to search for text within longer text passages. You have been assigned to implement this culture-aware feature using Visual C# .NET. What should you use to perform this search?

  • A. CultureInfo.CompareInfo

  • B. Array.Sort()

  • C. String.IndexOf()

  • D. String.IndexOfAny()

Question 37

You've written a COM component to supply weather information from the weather database to the weather Web page of your Web application. You are porting the Web application to .NET and now want to call the COM component methods from your ASP.NET Web application. The COM component is not used by any other application. Which of the following is the quickest way to use the COM component in the ASP.NET Web application?

  • A. Set a direct reference from your .NET client to the COM server.

  • B. Use the Type Library Importer to create an unsigned RCW for the COM component.

  • C. Use the Type Library Importer to create a signed RCW for the COM component.

  • D. Use PInvoke to instantiate classes from the COM component.

Question 38

You have designed an ASP.NET Web form that displays inventory information. When a product falls below the reorder level, you need to highlight the product information in a table so that it stands out to the user. Which method of highlighting is most accessible?

  • A. <BGCOLOR>

  • B. <BLINK>

  • C. <B>

  • D. <MARQUEE>

Question 39

You need to debug an ASP.NET Web application by using Visual Studio .NET, which is installed on your local machine. The Web application is deployed on a remote server. When you attempt to debug the application, you get a DCOM configuration error. Which of the following steps should you take to resolve this problem?

  • A. Add your account to the Users group on the local computer.

  • B. Add your account to the Users group on the remote computer.

  • C. Add your account to the Debugger Users group on the local computer.

  • D. Add your account to the Debugger Users group on the remote computer.

Question 40

You've developed a supplier evaluation system using Visual Studio .NET. While testing the program, you notice that the value of the TotalShipments variable sometimes becomes and causes an exception in the CalculateAvgShipDelay() method. You want your program to check the value of the TotalShipments variable and display an error message when the value of TotalShipments is . You also want the program to display this error message regardless of how you compile the program. Which of the following code segments should you write before making a call to the CalculateAvgShipDelay() method?

  • A. Trace.Assert(TotalShipments == 0, "TotalShipments is zero");

  • B. Trace.Assert(TotalShipments != 0, "TotalShipments is zero");

  • C. Debug.Assert(TotalShipments == 0, "TotalShipments is zero");

  • D. Debug.Assert(TotalShipments != 0, "TotalShipments is zero");

Question 41

You've developed an ASP.NET Web application that enables users to generate shipping labels. The program needs to generate thousands of shipping labels each day. You use the Trace object to monitor the application and log the results in the Windows event log. You need to monitor errors, warnings, and other informational messages generated by the Trace object. You should have flexibility in controlling the amount of information logged for your application, and you want to do this with minimal administrative effort. What should you do?

  • A. Compile the application using the /d:TRACE switch.

  • B. Define an environment variable named TRACE and set its value to true or false . In the program, check the value of the environment variable to indicate the amount of information you want your application to log.

  • C. Declare a compilation constant named TRACE and set its value to Error, Warning , or Info . In your program, use the #if, #else , and #endif directives to check the level of tracing you want.

  • D. Use the TraceSwitch class in your program, and then use TraceSwitch.Level property to check whether you need to log the performance. Set the level of TraceSwitch by using the application's configuration file.

Question 42

The configuration file of a Web application has the following contents:

 <system.diagnostics>    <switches>       <add name="BooleanSwitch" value="-1" />       <add name="TraceLevelSwitch" value="33" />    </switches> </system.diagnostics> 

You are using the following statements to create switch objects in your code:

 BooleanSwitch booleanSwitch =     new BooleanSwitch("BooleanSwitch", "Boolean Switch"); TraceSwitch traceSwitch =     new TraceSwitch("TraceLevelSwitch", "Trace Switch"); 

Which of the following options is correct regarding the values of these switch objects?

  • A. The booleanSwitch.Enabled property is set to false and traceSwitch.Level is set to TraceLevel.Verbose .

  • B. The booleanSwitch.Enabled property is set to true and traceSwitch.Level is set to TraceLevel.Verbose .

  • C. The booleanSwitch.Enabled property is set to false and traceSwitch.Level is set to TraceLevel.Error .

  • D. The booleanSwitch.Enabled property is set to false and traceSwitch.Level is set to TraceLevel.Info .

Question 43

You are debugging an ASP.NET Web application you wrote using Visual Studio .NET. Your code uses the Trace class to produce the debugging output. In which configuration(s) will this output be enabled?

  • A. In the default Release configuration only.

  • B. In the default Debug configuration only.

  • C. In both the default Release configuration and the default Debug configuration.

  • D. In neither the default Release configuration nor the default Debug configuration.

Question 44

You are testing a huge Web application running on the main testing server. Tracing is enabled on the Web application. You have difficulty testing the application from your desktop because the Web application is storing tracing information for only a few requests. You want the Web application to record tracing information for a larger number of requests, and you also want the tracing information to be displayed in the Web page along with the trace viewer. Which of the following options should you choose?

  • A. Set the <trace> element in the web.config application configuration file to the following:

     <trace enabled="true" pageOutput="true" localOnly= "false" /> 
  • B. Set the <trace> element in the web.config application configuration file to the following:

     <trace enabled="true" pageOutput="true" localOnly= "true" /> 
  • C. Set the <trace> element in the web.config application configuration file to the following:

     <trace enabled="false" pageOutput="true" localOnly= "true" /> 
  • D. Set the <trace> element in the web.config application configuration file to the following:

     <trace enabled="true" pageOutput="true" requestLimit= "50" localOnly="false" /> 
  • E. Set the <trace> element in the web.config application configuration file of the application to the following:

     <trace enabled="true" pageOutput="true" requestLimit= "50" localOnly="true" /> 
  • F. Set the <trace> element in the web.config application configuration file of the application to the following:

     <trace enabled="false" pageOutput="true" requestLimit= "50" localOnly="true" /> 
Question 45

You've used Visual C# .NET to create an assembly named Tracker.dll , which contains classes for tracking a shipment and is used by several applications, including both managed applications and unmanaged COM applications. The COM applications are already compiled and use late binding to invoke methods from the assembly. Which actions should you take to ensure that the assembly is properly deployed on the target machine? (Select all that apply.)

  • A. Create a strong name for the assembly using the Strong Name tool ( sn.exe ).

  • B. Register the assembly using the Assembly Registration tool ( regasm.exe ).

  • C. Create a type library for the application using the Type Library Exporter tool ( tlbexp.exe ).

  • D. Import the COM type library definition into an assembly using the Type Library Importer tool ( tlbimp.exe ).

  • E. Deploy the assembly to the Global Assembly Cache (GAC).

  • F. Deploy the assembly to the application's bin directory.

  • G. Deploy the assembly to the Windows system directory.

Question 46

You've used Visual C# .NET to develop a component named ReplicateWarehouseData . This component replicates the data used by the Warehousing application developed by the Warehouse Development team of your company. The Warehouse Development team needs to deploy the Warehousing application to its first three customers. How should it deploy the application? (Select two.)

  • A. Create a Merge module for the ReplicateWarehouseData component.

  • B. Create a Setup project that deploys the application and that includes the Merge module containing the component in the Setup project.

  • C. Copy the ReplicateWarehouseData component into the directory of the Warehousing application.

  • D. Create a Web Setup project to deploy the application that contains the code for the component.

Question 47

You've used Visual C# .NET to create an assembly named Tracker.dll , which contains classes for tracking a shipment. You need to deploy the assembly on the target computer in such a way that it can be accessed by multiple .NET applications. Which of the following actions should you take? (Select all that apply.)

  • A. Create a strong name for the assembly using the Strong Name tool ( sn.exe ).

  • B. Register the assembly using the Assembly Registration tool ( regasm.exe ).

  • C. Use XCOPY to deploy the assembly to the GAC.

  • D. Use FTP to deploy the assembly to the GAC.

  • E. Use the Setup and Deployment project to deploy the assembly to the GAC.

Question 48

You have created and tested an ASP.NET application on your local development server. The application makes heavy use of Web server controls, along with static HTML text. You have deployed the application to your company's production server via FTP. The production server has IIS 5.0 installed on it. The pages in the application are displaying in a jumbled fashion, with text present but none of the Web server controls present. What could be the problem?

  • A. Applications containing Web server controls cannot be deployed via FTP.

  • B. Web server controls do not function properly on a page that also contains static HTML text.

  • C. The ASP.NET worker process is not properly installed on the production server.

  • D. ASP.NET requires IIS 6.0 to function properly.

Question 49

You are creating a Web Setup project for a Web application. In the property pages for the Web Setup project, you have set the compression property to Optimized for speed . Which of the following options will be true as a result of this configuration option? (Select two.)

  • A. All the assemblies in the application will be precompiled to native code so that they run more quickly.

  • B. Resulting assemblies will be larger in size.

  • C. The setup package will be larger.

  • D. The setup project will run more quickly.

Question 50

Your application requires users to be members of the Accounting role to access a BalanceSheet object. Which .NET security feature should you use to ensure that your code has this capability?

  • A. Role-based security

  • B. Code-access security

  • C. SSL encryption

  • D. Type safety

Question 51

You've designed a Visual C# .NET application that uses the following code to check for membership in the Developers group:

 private void frmSecure_Load(object sender, System.EventArgs e) {      // Get the current principal object      Windows Principal prin = Thread.CurrentPricipal;     // Determine whether the user is a developer     Boolean developer = prin.IsInRole("Developers");     // Display the results on the UI     if(developer)         lblMembership.Text = "You are in the Developers group";     else         lblMembership.Text = "You are not in the Developers group"; } 

Users report that the code claims they are not in the Developers group even when they are. What must you do to fix this problem?

  • A. Use imperative security to ensure that your code has access to the Windows environment variables .

  • B. Create a WindowsIdentity object by using the WindowsIdentity.GetCurrent() method; then use this object to construct the WindowsPrincipal object.

  • C. Use the WindowsPrincipal.Name property to retrieve the user's name, and then use that name to call the IsInRole() method.

  • D. Call AppDomain.CurrentDomain.SetPrincipalPolicy (PrincipalPolicy.WindowsPrincipal) to specify the authentication mode.

Question 52

You've developed a project management system for your company that will be accessed through your company's intranet. The project management system provides an interface to be used by all employees to manage their projects in spite of their diverse nature. All the employees must log on using their Windows domain accounts to access this application. The web.config file of the project management application contains the following definition for the <authentication> element:

 <authentication mode="Windows"> 

The Web application runs on IIS 5.0 on Windows 2000 Advanced server. IIS is configured to use Basic authentication to authenticate the users. When you run the application, you notice that all users are allowed access to the application. Which of the following options should you take to allow access to only authenticated users? (Select all that apply.)

  • A. Add the following code in the web.config file of the Web application:

     <authentication mode="Windows"> <identity impersonate="true" /> 
  • B. Add the following code in the web.config file of the Web application:

     <authentication mode="Windows"> <authorization>    <deny users="?" /> </authorization> 
  • C. Configure IIS to enable Windows-integrated authentication rather than basic authentication for the Web application.

  • D. Configure IIS to disable anonymous access for the Web application.

Question 53

You have deployed an ASP.NET application in your company's intranet to manage the timesheets of associates in your company. The application uses Windows-integrated authentication to authenticate users. You allow only authenticated users to access the application. Which account will ASP.NET use to access resources?

  • A. The ASPNET account

  • B. The SYSTEM account

  • C. The IUSR_ComputerName account

  • D. The authenticated user's account

Question 54

You are developing a proof-of-concept program to evaluate role-based security for your .NET Framework application. You write the following code:

 PrincipalPermission pp1 = new PrincipalPermission("User1", "Role1"); PrincipalPermission pp2 = new PrincipalPermission("User2", "Role2"); PrincipalPermission pp3 = new PrincipalPermission("User3", "Role3"); PrincipalPermission perm1 =     (PrincipalPermission)pp1.Union(pp2); PrincipalPermission perm2 =     (PrincipalPermission)pp3.Union(perm1); 

Which of the following statements is correct with respect to the previous code? (Select all that apply.)

  • A. The expression perm1.IsSubsetOf(perm2) will evaluate to true .

  • B. The expression perm1.IsSubsetOf(perm2) will evaluate to false .

  • C. The expression perm2.IsSubsetOf(perm1) will evaluate to true .

  • D. The expression perm2.IsSubsetOf(perm1) will evaluate to false .

Question 55

You have deployed an ASP.NET application that displays the company's product catalog. Customers can select the product desired from the catalog and place orders. The application has been running successfully, but as the orders increase, you notice that the application is incapable of managing the load and performs slowly. The application also becomes unreachable whenever a hardware failure occurs. This is causing serious side effects in your business. You want to resolve this problem, so which of the following options should you select to deploy your Web application?

  • A. Single-server deployment

  • B. Web garden deployment

  • C. Cluster deployment

  • D. Web farm deployment

Question 56

You have created a Web user control named signup .ascx that encapsulates the controls used in your company for newsletter sign-up forms. Now you want to use this control in other Web applications. What must you do?

  • A. Install the control in the GAC.

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

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

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

Question 57

You are designing a new control for use in ASP.NET applications. The new control will be used to load an image from a disk file to an Image control at runtime. The control will not need a runtime user interface, but it must allow you to select a filename in the Properties window at design time. Which type of control should you create?

  • A. A control that inherits directly from the WebControl control

  • B. A control that inherits directly from the Label control

  • C. A control that inherits directly from the Control class

  • D. A control that inherits directly from the Component class

Question 58

You have created a custom component for your application that monitors a bidirectional parallel port for error messages. This component raises an event named PortError whenever an error message is detected . At that point, you must make the error code available to the control container. You want to use the best possible coding practices. Which of the following options should you choose to make the error code available to the container?

  • A. Place the error code in a property of the component for the container to retrieve.

  • B. Pass the error code as a parameter to the PortError event handler.

  • C. Define a global variable in a separate class and place the value in that variable.

  • D. Define a custom PortErrorEventArgs class that inherits from the EventArgs class to contain the error code, and pass an instance of the class as a parameter of the PortError event handler.

Question 59

Your application contains a Web user control called LogIn , which you have defined, in the LogIn.ascx file. You want to load this control in the Web page programmatically only if the user is not currently logged in to the Web site. The user control contains the following Control directive:

 <%@ Control ClassName="LogIn" Language="c#" AutoEventWireup="false"      Codebehind="LogIn.ascx.cs" Inherits="LogIn" %> 

You have added the following reference to the user control in the home Web page:

 <%@ Reference Control="LogIn.ascx" %> 

Which of the following options should you use to load the user control and set its properties in the Web page?

  • A.

     Control c = new Control("LogIn.ascx"); ((LogIn)c).ShowForgotPassword = true; 
  • B.

     Control c = new Control("LogIn.ascx"); ((LogIn)c).ShowForgotPassword = true; Controls.Add(c); 
  • C.

     Control c = LoadControl("LogIn.ascx"); ((LogIn)c).ShowForgotPassword = true; 
  • D.

     Control c = LoadControl("LogIn.ascx"); ((LogIn)c).ShowForgotPassword = true; Controls.Add(c); 
Question 60

You are designing a custom control for monitoring usage patterns of the Web pages. This control will log specific user actions into a SQL Server table. You will place this control on the Web forms, but the control does not require any visual representation at runtime. From which class should you derive this control?

  • A. Control

  • B. UserControl

  • C. Form

  • D. Component



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

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