Chapter 15. Practice Exam 2

Team-Fly    

Developing XML Web Services and Server Components with Visual C#™ .NET and the .NET Framework, Exam Cram™ 2 (Exam 70-320)
By Amit Kalani, Priti Kalani

Table of Contents


Chapter 15. Practice Exam #2

Question 1

You are designing a distributed application for your customers to track their online orders with your company. Thousands of customers will heavily use the application. For greater scalability, you need to make sure that the application can be deployed in a load-balanced configuration. How should you host the remotable object in this scenario?

  • A. As a server-activated object in Singleton activation mode

  • B. As a server-activated object in SingleCall activation mode

  • C. As a client-activated object that uses the HTTP channel

  • D. As a client-activated object that uses the TCP channel

Question 2

You are building a .NET Remoting server that will make an object named Product available to client applications. The client applications are built in .NET, and they include the class file for the Product object. Unfortunately, some of the processing information in the class file is confidential.

How should you remove this confidential information from the client applications without breaking their functionality?

  • A. Rewrite the client applications in C++ so that they do not contain managed code.

  • B. Create an interface, IProduct, that contains all the public members of the Product class. Implement the interface in the Product class. Ship only the interface with the client application.

  • C. Remove the implementation code from the client's copy of the Product class.

  • D. Rewrite the application as a Web service application instead of a Remoting application.

Question 3

You are designing a .NET Remoting server that will be hosted by IIS and ASP.NET. This server will make the Employee remotable object available to clients. You do not want to open ports on the firewall to the remote Employee object. Clients will be deployed on several different operating systems and platforms. Which channel and formatter should you use to implement this server?

  • A. HttpChannel and SoapFormatter

  • B. HttpChannel and BinaryFormatter

  • C. TcpChannel and SoapFormatter

  • D. TcpChannel and BinaryFormatter

Question 4

You are developing a .NET Remoting application that allows client programs to instantiate a class named Account. You want the remote object to be created on the server so that it can access the corporate financial information, which is stored on an intranet. However, you want client programs to control the creation and the lifetime of the remote objects. Which of the following methods of the RemotingConfiguration class would you choose to register the remotable class with the Remoting system on the client?

  • A. RegisterWellKnownServiceType()

  • B. RegisterWellKnownClientType()

  • C. RegisterActivatedServiceType()

  • D. RegisterActivatedClientType()

Question 5

You are developing a distributed application using the .NET Remoting infrastructure. The application exposes the Order object as a remote object to its client applications. The Order object consists of order details and an array of Product objects. The Product object consists of large numbers of data members. You want to provide your own code to control the serialization process of the Product object. What should you do? (Select two.)

  • A. Mark the Product class with the NonSerialized attribute.

  • B. Mark the Product class with the Serializable attribute.

  • C. Derive the Product class from the MarshalByRef class.

  • D. Make the Product class implement the ISerializable interface.

Question 6

You have designed a remotable class that allows the user to retrieve the latest stock price information for the selected stock symbols in her portfolio. You have hosted the remote object in the IIS and ASP.NET. The name of the remotable class is MyCompany.StockInfo, and it is stored in an assembly named StockInfo.dll. Which of the following remoting configurations would the client applications use in their configuration file to retrieve stock information correctly?

  • A.

     <client>     <wellknown             type=               "MyCompany.StockInfo, StockInfo"             url="tcp://www.MyCompany.com:8080/StockInfo.rem"     /> </client> 
  • B.

     <client>     <activated             type=               "MyCompany.StockInfo, StockInfo"             url="tcp://www.MyCompany.com:8080/StockInfo.rem"     /> </client> 
  • C.

     <client>     <wellknown             type=               "MyCompany.StockInfo, StockInfo"             url="http://www.MyCompany.com:8080/StockInfo.rem"     /> </client> 
  • D.

     <client>     <activated             type=               "MyCompany.StockInfo, StockInfo"             url="http://www.MyCompany.com:8080/StockInfo.rem"     /> </client> 
Question 7

You have designed a Windows application that is used by the shipping department of a large distributing company. The Windows application instantiates a remotable class hosted on Internet Information Services (IIS). The remotable class provides various services to the Windows application, such as address validation and calculation of shipping rates. When you deploy the application, users complain that when they click the Validate Address button, the Windows application freezes and they can't take further action until the address has been verified. What should you do to improve the application's responsiveness?

  • A. Use the binary formatter instead of the SOAP formatter.

  • B. Use the TCP channel to communicate instead of the HTTP channel.

  • C. Modify the remotable class to support asynchronous method calls.

  • D. Modify the Windows application to call the methods asynchronously on the remote object.

Question 8

The ASMX file in your Web service contains the following code:

 using System.Web.Services; [WebService(Namespace="http://my.org")] public class Account     : System.Web.Services.WebService {     public int32 Balance(string acctNumber)     {         // Stub to test function         return 5;     } } 

You compile the Web service and set a Web reference to it from a client application. However, you are unable to call the Balance() method from the client application. What must you do?

  • A. Add the [WebMethod()] attribute to the Balance() method.

  • B. Rewrite the Balance() method to have its return type set to void and have the return value passed through an output parameter.

  • C. Add the Balance() method to the WSDL file for the Web service.

  • D. Register the Web service with a UDDI Registry.

Question 9

You are using the Web Services Description Language tool to create a proxy class for a Web service. The Web service exposes a class named Product. You already have a Product class in your application. What should you do to allow both classes to coexist in the same application?

  • A. Rename the existing class.

  • B. Manually edit the generated proxy class to change the class name that it contains.

  • C. Use the /namespace option of the Web Services Description Language tool to specify a unique namespace for the new class.

  • D. Use the /out option of the Web Services Description Language tool to specify a unique output filename for the new class.

Question 10

You are invoking a Web service that returns a Hashtable object. Your client application is written in Visual C# .NET, whereas the Web service itself is written in Visual Basic .NET. The Web service is outside your corporate firewall. You receive an "object not found" error when you call the method that returns the Hashtable object. What could be the problem?

  • A. The client project and the server project are not written in the same language.

  • B. The firewall is blocking all SOAP calls.

  • C. The client project does not contain a reference to the System.Collections namespace.

  • D. The Hashtable object cannot be serialized.

Question 11

You are developing a SOAP extension that requires loading certain settings from the Windows Registry to initialize resources at startup. Which method should you use to load the settings from the Windows Registry?

  • A. GetInitializer()

  • B. Initialize()

  • C. ChainStream()

  • D. ProcessMessage()

Question 12

You are designing a SOAP extension that will run within a variety of Web service clients. This extension will monitor XML messages for confidential information and delete such information if it is found. In which message state should you invoke this SOAP extension?

  • A. BeforeSerialize

  • B. AfterSerialize

  • C. BeforeDeserialize

  • D. AfterDeserialize

Question 13

The customer service representatives in your company often receive calls from customers inquiring about the shipping status of their orders. You have been assigned to create an application that assists the customer service representatives to easily find the shipping status. You decide to create a Windows-based application that calls the XML Web services provided by the shipping and logistics company to retrieve the latest shipping status. When you test the application, the user of the application complains that the user interface of the application is very slow. You find that your program is waiting for the Web service call to execute. You need to design a solution that is most efficient. What should you do to make your application responsive?

  • A. Use the WaitHandle.WaitAll() method of the IAsyncResult.AsyncWaitHandle object.

  • B. Call the End() method of the XML Web service.

  • C. Use the WaitHandle.WaitAny() method of the IAsyncResult.AsyncWaitHandle object.

  • D. Supply a callback delegate to the Begin method of the XML Web service. After the XML Web service returns, a thread will invoke the callback method from the thread pool.

Question 14

You are a developer in a chemical-manufacturing company that manufactures chemicals used in a diverse range of targeted markets. You are developing a Web method, GetOrderDetails(), that will return the order details of an order placed by an customer. The customers usually call this Web service to retrieve and track order details of various orders placed with the company. The Web service needs to return order details for only those orders that are placed within the last six months. It also needs to receive order details from a legacy ERP system over a slow WAN link. The current implementation of the Web service is responding slowly and often gets a connection timed-out. The Web method of the Web service receives thousands of hits every day. You are responsible for improving the Web service's response and minimizing the hit to the legacy ERP system. What should you do?

  • A. Use caching to store the GetOrderDetails() Web method responses. Set the CacheDuration attribute of the Web method to 100.

  • B. Enable buffering to buffer the GetOrderDetails() Web method response. Set the BufferResponse attribute of the GetOrderDetails() Web method to true.

  • C. Use session state to store the order details placed within the last six months by the customer. Set the EnableSession property of the GetOrderDetails() Web method to true.

  • D. Use application state to store the order details placed within the last six months by the customer.

Question 15

You are a developer for a manufacturing company. Your company wants to have an XML Web service to share the latest design changes with partner companies. The design data is confidential and must be transmitted securely over the Internet. You do not want a system that accepts the username and password from the partner companies. Which of the following authentication mechanisms should you choose for this Web service?

  • A. Basic authentication

  • B. Digest authentication

  • C. Windows integrated authentication

  • D. Client certificate

Question 16

You are performing a final QA pass on a Web service client, and you discover that the name of one of the parameters on the Web service server has changed. All the documentation for the client has been printed, so you do not want to change the name of the client parameter. What should you do to fix this mismatch?

  • A. Use the SoapDocumentMethod attribute to specify the Bare parameter style for this method.

  • B. Use a SOAP extension on the client to detect the old parameter name and change it to the new parameter name before the message is sent.

  • C. Use the SoapDocumentMethod attribute with Use=SoapBindingUse.Literal to specify literal encoding for this method.

  • D. Use the XmlElement attribute to rename the parameter in the SOAP messages.

Question 17

You are designing an application to monitor your network and log XML messages. This application should run full-time, as long as the monitoring computer is running, whether or not there is a user logged on. Which sort of application should you design?

  • A. Web service

  • B. Serviced component

  • C. ASP.NET application

  • D. Windows service

Question 18

You are designing a network application that depends on several Windows services. You want to allow users to list all the services on the computer and select the ones that they want to monitor. Which class can you use to enumerate the running services?

  • A. ServiceBase

  • B. ServiceInstaller

  • C. ServiceController

  • D. ServiceProcessInstaller

Question 19

You are developing a Windows service by inheriting from the System.ServiceProcess.ServiceBase class. Which of the following handlers should you implement to make your Windows service useable?

  • A. OnStop()

  • B. OnStart()

  • C. OnPause()

  • D. OnContinue()

Question 20

You are developing a serviced component in Visual C# .NET. You have written code for the component and registered it with COM+ using regsvcs.exe. You later modify the code of the component, rebuild it, and register it again with COM+. After registration, you notice that the component appears in the COM+ catalog twice. What should you do to make the COM+ component appear only once in Component Services?

  • A. Build the component in release mode instead of in debug mode.

  • B. Disable object pooling for the COM+ component.

  • C. Use the Guid attribute to assign a constant GUID to the class.

  • D. Set the ClassInterface attribute with the ClassInterfaceType.None value so that you can hard-code the component's interfaces.

Question 21

You have created a serviced component that accepts vacation requests from employees for processing by the payroll system. You enable object-pooling services for the component and set Minimum Pool Size to 5 and Maximum Pool Size to 10. However, you have underestimated the demand for vacations, and 12 users attempt to use the application simultaneously. What is the result?

  • A. The first 10 requests for the object are satisfied with new instances. The last two requests are queued until an instance is available or until the specified timeout period elapses.

  • B. The first 10 requests for the object are satisfied with new instances. The last two requests fail with an "object not found" exception.

  • C. The first 10 requests for the object are satisfied with new instances. The last two requests are satisfied by recycling the first two objects, thus disconnecting the first two requests.

  • D. Component Services increases the pool size to 12 so that it can satisfy all the requests.

Question 22

You have created a component that makes use of COM+ transactions through the System.EnterpriseServices namespace. During the course of its activities, the component calls various methods of the ContextUtil class. Which of these methods can the class use to indicate that its work is finished and that it approves of committing the transaction? (Select the two best answers.)

  • A. DisableCommit()

  • B. EnableCommit()

  • C. SetAbort()

  • D. SetComplete()

Question 23

You create a queued component named ShipPaints that is used to ship paints whose requests appear in an asynchronous fashion. The ShipPaints class includes the following code:

 namespace MyCompany {    public interface IShipPaints    {      bool Ship(Paint o);    }   [Transaction(TransactionOption.Required)]    [InterfaceQueuing(Enabled=true,             Interface="IShipPaints")]    public class ShipPaints :                 ServicedComponent,                 IShipPaints    {       public bool Ship(Paint o)       {         // code to update various databases       }    } } 

You get no compilation errors, but when you register this component using the .NET Services Installation tool (regsvcs.exe), you get an error message: "Queuing not supported on interface 'IshipPaints.'" What should you do to resolve this error?

  • A. Apply the AutoComplete attribute to the ShipPaints class.

  • B. Apply the following attribute to the class:

     [ApplicationQueuing( Enabled=true, QueueListenerEnabled=true)] 
  • C. Apply the InterfaceQueuing attribute to the IShipPaints interface rather than to the ShipPaints class.

  • D. Change the interface definition as follows and then change ShipPaints to implement this interface.

     public interface IShipPaints {    void Ship(OrderInfo o); } 
Question 24

You are developing a client application that needs to invoke an XML Web service. The Web service uses Basic authentication to authenticate the users. You write the following code segment to invoke the Web service:

 01: // Create an instance of the Web service class 02: ProductMfg.Catalog catServ = new ProductMfg.Catalog(); 03: // Pass credentials to the Web service 04: //Invoke a Web method on the Web service 05: double price = catServ.GetPrice(productID); 

Which of the following code segments would you insert between Lines 3 and 4 in this code to pass the client credentials to the Web service?

  • A.

     CredentialCache credentialCache = new CredentialCache(); NetworkCredential credentials = new NetworkCredential(); credentialCache.Add(new Uri(catServ.Url),                        "Basic", credentials); catServ.Credentials = credentialCache; 
  • B.

     CredentialCache credentialCache = new CredentialCache(); NetworkCredential credentials = new       NetworkCredential("username","password","domain"); credentialCache.Add(new Uri(catServ.Url),                        "Basic", credentials); catServ.Credentials = credentialCache; 
  • C.

     Dim cc As CredentialCache  = New CredentialCache() Dim credentials As NetworkCredential =  _     New NetworkCredential() cc.Add(New Uri(catServ.Url), _     "Basic", credentials) catServ.Credentials = credentials CredentialCache credentialCache = new CredentialCache(); NetworkCredential = new NetworkCredential(); credentialCache.Add(New Uri(catServ.Url), "Basic", credentials); catServ.Credentials = credentials; 
  • D.

     CredentialCache credentialCache = new CredentialCache(); NetworkCredential credentials = new       NetworkCredential("username","password","domain"); credentialCache.Add(new Uri(catServ.Url),                        "Basic", credentials); catServ.Credentials = credentials; 
Question 25

ComponentWare, Inc., supplies a range of COM components to provide advanced communications capabilities to a wide variety of applications. In the last management meeting, company managers decided to create a .NET version of these components. Some of the clients of the company are already porting to .NET and require an RCW for the component immediately. What should ComponentWare do?

  • A. Use the Type Library Importer tool to create and sign a PIA for the component.

  • B. Use the Type Library Exporter tool to create and sign a PIA for the component.

  • C. Set a reference to the component from any Visual C# .NET project to create an RCW for the component.

  • D. Create a class that uses platform invoke to call functions from the component.

Question 26

You wrote 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. You now want to call the methods of the COM component 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 tool to create an unsigned RCW for the COM component.

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

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

Question 27

Your project contains the following API declaration:

 [DllImport("kernel32.dll", CharSet=CharSet.Auto)] public static extern int GetComputerName(     String buffer, ref uint size); 

The project also contains code to use this API to display the computer name:

 public static void ShowName() {     String buf = "";     UInt32 intLen=128;     Int32 intRet;     // Call the Win API method     intRet = GetComputerName(       buf, ref intLen);     Console.WriteLine(        "This computer is named " +        buf.ToString()); } 

Users report that no computer name is displayed. What should you do?

  • A. Use ref with the variable buf in the call to the GetComputerName() function.

  • B. Replace the use of String with StringBuilder in the code.

  • C. Tell the users that their computers have no names set in their network properties.

  • D. Use out with the variable buf in the call to the GetComputerName() function.

Question 28

You are creating a schema file to represent the Customers table in your database. You need to represent a field named CustomerContact in this schema. Data entered in the CustomerContact field is a string with up to 25 characters. What should you use to represent this field in the XML Schema?

  • A. Attribute

  • B. Simple type

  • C. Element

  • D. Complex type

Question 29

You develop a Visual C# .NET application that displays supplier data in a DataGrid control. The supplier data is stored 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; 

However, when you run the program, the results are not as expected. How should you change the 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 30

You create a .NET application that queries data from a SQL Server database. You use SqlConnection object to connect to the database. As soon as the database operation is completed, you want to make sure that any pending database transactions are rolled back and that the 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 31

You develop a .NET application that allows the users to view and modify recently placed orders. Your application needs to display data from OrderHeader and OrderDetails data tables. Information from OrderHeader is displayed in a ListBox control; the 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 should display 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 table.

  • 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 32

You need to develop a .NET 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 ProcessOrder 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 33

You are working with a SQL Server database that contains a table named Patients and a table named Visits. The Patients table contains columns PatientID (a unique identifier for the patient and the primary key of the table) and PatientName (the name of the patient). The Visits table contains the columns VisitID (a unique identifier for the visit and the primary key of the table), PatientID (a foreign key that points to the PatientID column in the Patients table), VisitCost (the bill for the visit), and VisitDate (the date of the visit).

You want to write a query that returns the number of visits that each patient has made, together with the patient's name, provided that the total cost of the visits is at least $100. Which SQL statement should you use?

  • A.

     SELECT Patients.PatientName, Count(Visits.VisitID) FROM Patients INNER JOIN Visits  ON Patients.PatientID = Visits.PatientID GROUP BY Patients.PatientName WHERE Sum(Visits.VisitCost)>=100 
  • B.

     SELECT Patients.PatientName, Count(Visits.VisitID) FROM Patients INNER JOIN Visits  ON Patients.PatientID = Visits.PatientID GROUP BY Patients.PatientName WHERE Visits.VisitCost >=100 
  • C.

     SELECT Patients.PatientName, Count(Visits.VisitID) FROM Patients INNER JOIN Visits  ON Patients.PatientID = Visits.PatientID GROUP BY Patients.PatientName HAVING Sum(Visits.VisitCost)>=100 
  • D.

     SELECT Patients.PatientName, Count(Visits.VisitID) FROM Patients INNER JOIN Visits  ON Patients.PatientID = Visits.PatientID GROUP BY Patients.PatientName HAVING Visits.VisitCost >=100 
Question 34

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. The data that you will read from the database is huge, so you want to retrieve the data with very little impact on the server resources and you want to maximize the performance. Which object should you use to load the data from the database?

  • A. DataSet

  • B. DataTable

  • C. SqlDataReader

  • D. OleDbDataReader

Question 35

You allow users to edit product information on a DataGrid control that is bound to a DataSet object. When the 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 that deleted rows are reappearing 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 have not set the DeleteCommand property of the SqlDataAdapter object.

Question 36

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

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

You have created a 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 @SalesID parameter for the 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 37

You develop an application named ProcessOrder using Visual C# .NET. Your application receives orders from customers in an XML file named Orders.xml. The Orders.xml file does not include any schema. Which of the following methods should you use to load the 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 38

You develop a .NET application that allows users to add new regions in the SQL Server Sales database. You use the following Visual C# .NET code segment to add regions:

 SqlCommand command = new SqlCommand(null, sConn); command.CommandText =     "INSERT INTO Region (RegionID, " +     "RegionDescription) VALUES (@rid, @rdesc)"; command.Parameters.Add ( "@rid", rid); command.Parameters.Add ( "@rdesc", rdesc); command.ExecuteNonQuery(); 

Each time the users use this application, they may add several regions. Which of the following options will you use to ensure optimum performance of the application?

  • A. Use the SqlCommand.ExecuteReader() method instead of the SqlCommand.ExecuteNonQuery() method.

  • B. Call SqlCommand.Prepare() the method before each call to the SqlCommand.ExecuteNonQuery() method.

  • C. Call the SqlCommand.Prepare() method before the first call to the SqlCommand.ExecuteNonQuery() method.

  • D. Call the SqlCommand.ResetCommandTimeout() method before each call to the SqlCommand.ExecuteNonQuery() method.

Question 39

Your application's database includes a table of orders that contains three million rows of data. Each row includes the order date as well as other information. Your application allows the user to enter a date and then displays all the orders placed on that date. Which strategy should you use to retrieve the orders?

  • A. Create a parameterized stored procedure that accepts the order date as a parameter.

  • B. Retrieve the orders table to a DataSet object and build a DataView object to contain only the required orders.

  • C. Create an ad hoc SQL statement that includes the date entered by the user as part of the SQL statement.

  • D. Create a view on the server that includes only the required orders.

Question 40

You have defined a stored procedure in your database as follows:

 CREATE PROC GetCustomers   @Country varchar(25) AS   SELECT * FROM Customers   WHERE Country = @Country 

The stored procedure executes without error from SQL Query Analyzer. Now you are using code behind a form with this stored procedure. The form includes a SqlConnection object named cnn and a DataGrid control named dgCustomers:

 SqlCommand cmd = new SqlCommand(); DataSet ds = new DataSet(); SqlDataAdapter da = _  new SqlDataAdapter(); cmd.Connection = cnn; cmd.CommandText = "GetCustomers"; cmd.Parameters.Add(new SqlParameter(  "@Country", SqlDbType.VarChar, 25)); cmd.Parameters["@Country"].Value =    "France"; da.SelectCommand = cmd; da.Fill(ds, "Customers"); dgCustomers.DataSource = ds; dgCustomers.DataMember = "Customers"; 

When you run the code, you receive an unhandled exception of the type System.Data.SqlClient.SqlException on the line that calls the Fill() method. What should you do to fix this error?

  • A. Explicitly set the CommandType object of the SqlCommand object to CommandType.StoredProcedure.

  • B. Replace the stored procedure with an ad hoc SQL statement containing the actual country string.

  • C. Use a SqlDataReader object instead of a DataSet object to retrieve the data.

  • D. Call the Open() method of the SqlConnection object before calling the Fill() method of the DataAdapter.

Question 41

You develop desktop applications for a large university. Your new project is to write a Visual C# .NET application that allows professors to maintain the score of the students. You place a DataGrid control on the Windows form and bind the data grid to a DataView object. You allow professors to make changes in the data grid by adding new rows, by modifying existing rows, and by deleting existing rows. You now want to place a command button that allows 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 42

Your application contains the following XML file:

 <?xml version="1.0" encoding="utf-8" ?> <Trials>   <Trial Trial>     <Courtroom>1</Courtroom>   </Trial>   <Trial Trial>     <Courtroom>4</Courtroom>   </Trial>   <Trial Trial>     <Courtroom>3</Courtroom>   </Trial> </Trials> 

Your application uses the ReadXmlSchema() method of the DataSet object to create a DataSet object with an appropriate schema for this XML file. Which of the following mappings between XML entities and DataSet object entities will this method create?

  • A. Trials and Trial will become DataTable objects. Courtroom will become a DataColumn object. TrialID will not be mapped.

  • B. Trials and Trial will become DataTable objects. TrialID will become a DataColumn object. Courtroom will not be mapped.

  • C. Trials and Trial will become DataTable objects. TrialID and Courtroom will become DataColumn objects.

  • D. Trials will become a DataTable object. Trial and Courtroom will become DataColumn objects. TrialID will not be mapped.

Question 43

You are working programmatically with an XML document. You don't know anything about the structure of this document other than that it is valid XML. Which of these methods can you use to retrieve the root element of the document?

  • A. Load the document into an XmlDocument object and retrieve its DocumentElement property.

  • B. Load the document into an XmlNode object and retrieve its DocumentElement property.

  • C. Load the document into an XmlDocument object and retrieve its DocumentType property.

  • D. Load the document into an XmlNode object and retrieve its DocumentType property.

Question 44

You are using XPath to retrieve information from an XML file of electronic components. Some of the components are grouped into assemblies and subassemblies, and this grouping is represented in the hierarchy of the XML file. You want to write an XPath expression to select every occurrence of the Volts attribute in the XML file, regardless of the level where this attribute appears. Which XPath expression can you use for this purpose?

  • A. ./@Volts

  • B. ./Volts

  • C. //@Volts

  • D. //Volts

Question 45

Your application contains the following code to update a SQL Server database via an XML DiffGram:

 private void btnUpdate_Click(     object sender, System.EventArgs e) {     // Connect to the SQL Server database     SqlXmlCommand sxc =      new SqlXmlCommand(      "Provider=SQLOLEDB;" +      "Server=(local);database=Northwind;" +      "Integrated Security=SSPI");     // Set up the DiffGram     sxc.CommandType =         SqlXmlCommandType.DiffGram;     sxc.SchemaPath = "..\diffgram.xsd"     FileStream fs =      new FileStream(@"..\..\diffgram.xml",         FileMode.Open);     sxc.CommandStream = fs;     // And execute it     sxc.ExecuteNonQuery();     MessageBox.Show(         "Database was updated!"); } 

The code executes and the data specified in the diffgram.xml file is properly updated when you run the application on your own computer. However, when you deploy the application to a production computer, you receive a System.IO.FileNotFoundException. You have verified that the production computer has correct installation of SQL Server and the Northwind database. What action should you take to fix this problem?

  • A. Move the DiffGram files to the root directory on the production computer.

  • B. Install the .NET Framework SP2 on the production computer.

  • C. Install the SQLXML package on the production computer.

  • D. Modify the connection string to explicitly use the name of the production computer.

Question 46

The configuration file of an 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 47

Your application uses version 2.3.0.0 of the FunGraph assembly. The producer of the assembly has issued version 2.3.l.0 of the assembly, together with a publisher policy file that dictates using 2.3.1.0 in place of 2.3.0.0 in all applications. You discover after testing that one of your applications, named DiskGraph, which previously worked with 2.3.0.0, fails with 2.3.1.0. You want only this application to use the old version of the assembly, while letting all other applications use the new version. What should you do?

  • A. Copy version 2.3.0.0 of the assembly from the GAC to the folder containing DiskGraph.exe.

  • B. Add an administrator policy specifying that requests for 2.3.0.0 should be satisfied with 2.3.0.0.

  • C. Add the element <publisherPolicy apply="no"/> to the DiskGraph.exe.config file.

  • D. Delete the publisher policy from your computer.

Question 48

You need to debug an ASP.NET Web application by using Visual Studio .NET 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 Main Users group on the local computer.

  • B. Add your account to the Main 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 49

You develop a supplier evaluation system using Visual Studio .NET. While testing the program, you notice that the value of TotalShipments variable sometimes becomes 0 and causes an exception within the CalculateAvgShipDelay() method. You want your program to check the value of TotalShipments variable and display an error message when the value of TotalShipments is 0. You 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 50

You develop 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 of controlling the amount of information logged for your application, and you want to do this with minimum administrative efforts. 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 that you want for your application to be logged.

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

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

Question 51

You are debugging an ASP.NET Web application that 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 52

You are testing a huge Web application running on the main testing server, and you have enabled tracing in the application. You find it difficult to test 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, 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 of the application to:

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

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

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

     <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:

     <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:

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

You use Visual C# .NET to develop a component named ReplicateWarehouseData. This component replicates the data used by the Warehousing application that is 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?

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

  • B. Create a Setup project to deploy the application, and include 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 54

You use Visual C# .NET to create an assembly named Tracker.dll. Tracker.dll 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 by 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 Global Assembly Cache.

  • D. Use FTP to deploy the assembly to the Global Assembly Cache.

  • E. Use Setup and Deployment project to deploy the assembly to the Global Assembly Cache.

Question 55

You develop an 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 error returned from the SQL Server .NET data provider. Which of the following options should you choose?

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

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

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

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

Question 56

You have deployed a Web service application that enables partners to access the product catalog and place orders directly into the system. The application has been running successfully, but slowly as the number of orders are increasing, you notice that the application cannot manage the load and performs slowly. The application also becomes unreachable whenever there is a hardware failure. This is causing serious impact on the business of your company. You want to resolve this problem. Which of the following options should you select to deploy your Web service application?

  • A. Single-server deployment

  • B. Web garden deployment

  • C. Cluster deployment

  • D. Web farm deployment

Question 57

Your application requires the user to be a member 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 58

You design 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 make sure that your code has access to the Windows environment variables.

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

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

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

Question 59

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 this 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 60

You are developing a serviced component named Controller. You have enabled role-based security for this component. You do not want to invoke any methods of the Controller component if the security of the component is turned off (for example, using the Windows Component Services administrative tool). Which of the following modifications should you make to your serviced component?

  • A. Add the following code to the methods of the Controller class:

    [View full width]

    if (!ContextUtil.SecurityEnabled()) { throw new SecurityException("Security must be enabled for this method to execute graphics/ccc.gif successfully"); }
  • B. Add the following code to the methods of the Controller class:

     if(!ContextUtil.SecurityEnabled()) {     ContextUtil.DisableCommit(); } 
  • C. Apply the following attribute to the Controller class:

     [ApplicationAccessControl(AccessChecksLevel=        AccessChecksLevelOption.ApplicationComponent)] 
  • D. Apply the following attribute to the Controller class:

     [ComponentAccessControl(Value=true)] 
Question 61

Your assembly is a member of five code groups, as follows:

  • EnterpriseA, at the enterprise level, grants Registry, Environment, FileDialog, and FileIO permissions to the code.

  • EnterpriseB, at the enterprise level, grants FileDialog permissions to the code.

  • MachineA, at the machine level, grants Registry, Environment, and FileIO permissions to the code.

  • MachineB, at the machine level, grants Environment and FileIO permissions to the code. This code group has its LevelFinal bit set.

  • UserA, at the user level, grants FileIO permissions to the code.

Which of these permissions will the code be granted as a result of its membership in these code groups?

  • A. FileIO

  • B. Registry, Environment, and FileIO

  • C. Registry, Environment, FileIO, and FileDialog

  • D. FileDialog, Environment, and FileIO

Question 62

You have written a serviced component and now need to debug it when it's being used by a client process. The serviced component is stored in a file named Books.dll and is a Library application. The client process is named OrderBooks.exe. To which process should you attach the debugger to trace calls within the serviced component?

  • A. Books.dll

  • B. OrderBooks.exe

  • C. aspnet_wp.exe

  • D. dllhost.exe

Question 63

Your serviced component's method fails when a particular variable equals 197. Unfortunately, you cannot predict when this will happen. You want to write minimal code. Which debugging tool should you use to investigate the problem?

  • A. Locals window

  • B. Output window

  • C. Immediate window

  • D. Conditional breakpoint

Question 64

You are using IIS to authenticate users of an ASP.NET application. Part of your corporate security guidelines states that passwords must never cross the Internet in clear text. Which authentication methods can you use? (Select two.)

  • A. Anonymous

  • B. Basic

  • C. Digest

  • D. Windows integrated

Question 65

You have developed a serviced component named Inventory that is a part of the Warehouse COM+ application. You have applied the SecurityRole attribute on the serviced component to allow access to only the members of the Controller and Vendors roles. As a result of a recent acquisition, you now have a new group of users, named Suppliers, that needs to be assigned to the Vendors role. Which of the following actions should you take?

  • A. Use the Component Services tool to add a new role named Suppliers.

  • B. Use the Component Services tool to add the Suppliers group to the existing Vendors role.

  • C. Add another SecurityRole attribute to the Inventory class for the Suppliers group.

  • D. Modify the Vendors SecurityRole attribute on the Inventory class to include the Suppliers group.


    Team-Fly    
    Top


    MCAD Developing XML Web Services and Server Components with Visual C#. NET and the. NET Framework Exam Cram 2 (Exam Cram 70-320)
    Managing Globally with Information Technology
    ISBN: 789728974
    EAN: 2147483647
    Year: 2002
    Pages: 179

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