Monday, March 7, 2011

Learning WCF4: Default Endpoint

Learning WCF 4 : Default endpoint

Prior to WCF 4 , i.e. in WCF3 , there were three major steps when one talked about WCF Service.
  1. Creating WCF Service Contract (IService)
  2. Implementing the contract(Service1.svc)
  3. Making an endpoint for the service , which could be done using code or web.config file . Majority of times it was done using web.config file.
  4. Hosting the service
  5. Consuming that service

Most of the times developers felt that creating a basic wcf service even , they need to play with web.config file, which was a tedious task. Thus Microsoft came up with concept of DEFAULT ENDPOINT in WCF4.

So enjoy coding your first program with WCF4 , without creating endpoint.

Step 1:
Open Visual Studio IDE 2010
Fileà New Project à WCF Tab.
Choose template WCF Service Application, Name it BasicWcf
Step 2:
Delete default code generated from Contarct IService1 , so that it should look like following .


namespace BasicWcf
{
    [ServiceContract]
    public interface IService1
    {

        [OperationContract]
        string GetData(int value);

    }

}

Similary do for Service class : so that it looks like following
namespace BasicWcf
{
   public class Service1 : IService1
    {
        public string GetData(int value)
        {
            return string.Format("You entered: {0}", value);
        }

    }
}

Step3: Open web.config file and delete following line for the time being .

 
Step 4: Build the service

Step 5: Add new project to the application

 

Step 6: Add service refrence in this console app to the service created.

 
Step 7: Click on discover .
 
Step 8:  Add the following in the Program.cs
using ConsoleApplication1.ServiceReference1;
namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            Service1Client proxy = new Service1Client();
            var res=proxy.GetData(2403);
            Console.WriteLine(res);
            Console.ReadKey(true);

        }
    }
}


Step 9: Build the console app.
Step 10 : Set it as start up project.

Step 11; Run the project (F5)

Output :

Summary : This article shows how WCF 4 works with default endpoint . Default endpoint in WCF uses basicHttpBinding.

To check this just add following code in the Program.cs file and run again.

            var bindingName = proxy.Endpoint.Binding.Name;
            Console.WriteLine(bindingName);
            Console.ReadKey(true);

Monday, February 28, 2011

MCQ: XML More Ques

Which of the following XML documents are well-formed?
A. <firstElement>some text goes here
<secondElement>another text goes here</secondElement>
</firstElement>
B. <firstElement>some text goes here</firstElement>
<secondElement> another text goes here</secondElement>
C. <firstElement>some text goes here
<secondElement> another text goes here</firstElement>
</secondElement>
D. </firstElement>some text goes here
</secondElement>another text goes here <firstElement>
ANSWER : A


Disadvantages of DTD are
(i)   DTDs are not extensible
(ii)  DTDs are not in to support for namespaces
(iii) there is no provision for inheritance from one DTDs to another
A. (i) is correct
B. (i),(ii) are correct
C. (ii),(iii) are correct
D. (i),(ii),(iii) are correct
ANSWER :D



To use the external DTD we have the syntax
A.  <?xml version=”1.0” standalone=”no”?>
<! DOCTYPE DOCUMENT SYSTEM “order.dtd”?>
B.  <?xml version=”1.0” standalone=”yes”?>
<! DOCTYPE DOCUMENT SYSTEM “order.dtd”?>
C. <?xml version=”1.0” standalone=”no”?>
<! DOCTYPE DOCUMENT “order.dtd”?>
D. <?xml version=”1.0” standalone=”yes”?>
<! DOCTYPE DOCUMENT SYSTEM “order.dtd”?>
ANSWER : A



A schema describes
(i) grammer
(ii) vocabulary
(iii) structure
(iv) datatype of XML document
A. (i) & (ii) are correct
B. (i),(iii) ,(iv) are correct
C. (i),(ii),(iv) are correct
D. (i),(ii),(iii),(iv) are correct
ANSWER : D




Attribute of the document interface in DOM is/are
(i)doctype
(ii)implementation
(iii)documentElement
which are read only attributes
A. (i) only
B. (ii) only
C. (ii),(iii) only
D. all
ANSWER : D


A textual object is a well formed XML document if
(i) Taken as a whole it matches the production labeled document.
(ii) Each of the parsed entity which is referenced directly or indirectly within the document can be well formed
A. (i) is correct
B. (ii)is correct
C. both are correct
D. None are correct
ANSWER : C



The transformation of XML document in to another type of document by XSLT can be done by
(i)In the server
(ii)In the client
(iii)With a separate program
A. only(i) & (ii)
B. only (ii) & (iii)
C. all are correct
D. only (i) & (iii)
ANSWER : C

You create the definition for a Vehicle class by using the following code segment. Public Class Vehicle <XmlAttribute(AttributeName:="category")> _ Public vehicleType As String Public model As String <XmlIgnore> _ Public year As Integer <XmlElement(ElementName:="mileage")> _ Public miles As Integer Public condition As ConditionType Public Sub New() End Sub Public Enum ConditionType <XmlEnum("Poor")> BelowAverage <XmlEnum("Good")> Average <XmlEnum("Excellent")> AboveAverage End Enum End Class You create an instance of the Vehicle class. You populate the public fields of the Vehicle class instance as shown in the following table: MemberValuevehicleTypecarmodelraceryear2002miles15000conditionAboveAverage You need to identify the XML block that is produced when this Vehicle class instance is serialized. Which block of XML represents the output of serializing the Vehicle instance?
A. <?xml version="1.0" encoding="utf-8"?> <Vehicle xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"" vehicleType="car"> <model>racer</model> <miles>15000</miles> <condition>AboveAverage</condition> </Vehicle>
B. <?xml version="1.0" encoding="utf-8"?> <Vehicle xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" category="car"> <model>racer</model> <mileage>15000</mileage> <condition>Excellent</condition> </Vehicle>
C. <?xml version="1.0" encoding="utf-8"?> <Vehicle xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" category="car"> <model>racer</model> <mileage>15000</mileage> <conditionType>Excellent</conditionType> </Vehicle>
D. <?xml version="1.0" encoding="utf-8"?> <Vehicle xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <category>car</category> <model>racer</model> <mileage>15000</mileage> <condition>Excellent</condition> </Vehicle>
Answer: B

You are creating a .NET Remoting object. You want to add code to the object to log error messages and warning messages. You want the log messages written to both a log file and to the Windows application log. Which code segment should you use?
A.  EventLog eventLog = new EventLog(“testkobj”);
      FileStream fileLog = File.Create(“testkobj.log”;
      Trace.WriteLine(eventLog, “sample message”);
      Trace.WriteLine(fileLog, “sample message”);
B.  EventLog eventLog = new EventLog(“testkobj”);
      FileStream fileLog = File.Create(“testkobj.log”);
      Trace.Write(eventLog);
      Trace.Write(fileLog);
      Trace.WriteLine(“sample message”);
C.  Trace.Listeners.Add(new
      EventLogTraceListener(“testkobj”));
      Trace.Listeners.Add(
      new TextFileTraceListener(“testkobj.log”));
      Trace.WriteLine(“sample message”);
D.  Trace.Listeners.Add(new EventLogTraceListener());
      Trace.Listeners.Add(
      new.TextFileTraceListener(“testkobj.log”));
      Trace.WriteLine(“sample message”);
ANSWER : C


You create a serviced component named SessionDispenser. This computer is in the Gsoft. Utilities assembly and is registered in a COM+ server application. SessionDispenser has multiple callers. You discover that there are logic problems in the Create New Session method. You want to debug any calls to this method. What should you do?
A. Open the SessionDispenser solution. Set a breakpoint on the CreateNewSession method. Start the debugger.
B. Attach the debugger to the client process. Set a breakpoint on the SessionDispenser.CreateNewSession method.
C. Attach the debugger to the Gsoft.Utilites.exe process. Set a breakpoint on the CreateNewSession method.
D. Attach the debugger to a Dllhost.exe process. Set a breakpoint on the CreateNewSession method.
ANSWER : C


You create an XML Web service named LatLong that converts street addresses to latitude and longitude coordinates. Gsoft Inc. charges for this service and allows only existing customers to use the service. If a customer ID is not passed as part of a SOAP header, you want the service to refuse the request. You want these service refusal messages to be logged to an event log named LatLongLog. You anticipate that there will be a lot of these log entries over time. A string object named refusalMessage contains the message to log. Which code segment should you use?
A. Event log = new EventLog(“LatLongLog”);
     log.WriteEntry(refusalMessage, EventLogEntryType.Error);
B. EventLog log = new EventLog();
     log.Source = “LatLongLog”;
     log.WriteEntry(refusalMessage, EventLogEntryType.Error);
C. if (!EventLog.SourceExists(“LatLongSource”)) {
     EventLog.CreateEventSource(“LatLongSource”,
    “LatLongLog”);
      }
     EventLog.WriteEntry(“LatLongSource”,
     refusalMessage, EventLogEntryType.Error);
D. if (!EventLog.SourceExists(“LatLongSource”)) {
     EventLog.CreateEventSource(“LatLongSource”,
     “LatLongLog”;
     }
     EventLog log = new EventLog(“LatLongLog”);
     log.WriteEntry(refusalMessage, EventLogEntryType.Error);
ANSWER : C


You create a serviced component named GsoftOrderProcessor. OrderProcessor implements the IOrderinit interface. The component and the interface contain the following code segments:
[Guid(“0B6ABB29-43D6-40a6-B5F2-83A457D062AC”)]
[InterfaceType(ComInterfaceType.InterfaceIsDual)]
public interface IOrderInit {
// IOrderInit methods go here.
}
public class OrderProcessor: ServicedComponent, IOrderInit {
// OrderProcessor methods go here.
}
You discover that every time you rebuild GsoftOrderProcessor, existing unmanaged client code fails. The HRESULT for the exception is 0x80040154. The exception includes the following message: “Class not registered”. You need to resolve this problem. What should you do?
A. Add a Guid attribute to the GsoftOrderProcessor class.
B. Add a ComImport attribute to the IOrderInit interface.
C. To the GsoftOrderProcessor class, add the following attribute:
     [ClassInterface(ClassInterfaceType.AutoDual)]
D. To the end of every method, add the following line of code:
     Marshal.ReleaseComObject(this);
ANSWER : A


You create an XML Web service named PostalCode. Your project source includes a code-behind file and a file named PostalCode.asmx. During implementation, you use the Debug class to record debugging log messages, to verify values, and to report debugging failures. You want to deploy PostalCode to a production computer. You do not want any of the debugging code to execute on the production computer. What should you do?
A. Set the project’s active configuration to Release and rebuild the DLL.
B. Modify the trace element of the Web.config file by setting the enabled attribute to “false”.
C. Modify the compilation element of the Web.config file by setting the debug attribute to “false”.
D. Add code to the constructor of the PostalCode class to set the AutoFlash property of the Debug class to false.
ANSWER : C


You create an XML Web service named TimeTKService. Each time TimeTKService is started, it checks for the existence of an event log named TimeTKServiceLog. If TimeServiceLog does not exist, TimeTKService creates it. You discover that when TimeTKService creates TimeTKServiceLog, it throws a System.Security.SecurityException. The exception includes the following message: “Requested registry access is not allowed”. You need to resolve this problem. What should you do?
A. Configure Inetinfo.exe to run as the local administrator user account.
B. Create an installer for TimeTKService, and create the new event log in the installer code.
C. Modify the Web.config file by adding an identity element to impersonate the LOGON user specified by Internet Information Services (IIS).
D. Modify the permissions of the HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Eventlog registry key to give full control to the IUSR_computername user account.
ANSWER :  A


You are creating an XML Web service named GsoftCustomer that provides customer information. You write code to keep track of error messages, warning messages, and informational messages while the service is running. You use the Trace class to write the messages to a log file. On test computers, you want to see error messages and warning messages. On deployment computers, you want to see error messages, but not warning messages. Which two code segments should you use? (Each correct answer presents part of the solution. Choose two)
A. private static TraceSwitch mySwitch;
    static BankCustomer {
    mySwitch = new TraceSwitch(“tswitch”,“a trace switch”);}
B. public static TraceLevel level;
    static BankCustomer {level = TraceLevel.Error;}
C. Trace.WriteLineIf(mySwitch.TraceError,“An error occurred.”);
     Trace.WriteLineIf(mySwitch.TraceWarning,“Warning message”);
D. Trace.WriteLineIf(level == TraceLevel.Error,“The operation succeeded.”);
     Trace.WriteLineIf(level == TraceLevel.Warning,“Warning message”);
E. Trace.WriteLineIf(mySwitch != null,“An error occurred.”);
     Trace.WriteLineIf(mySwitch != null,“Warning Message”);
F. Trace.WriteIf(level != TraceLevel.Off,“An error occurred.”);
     Trace.WriteIf(level != TraceLevel.Off,“Warning message”);
ANSWER : A, C


You create a serviced component named TestKScheduler. TestKScheduler is registered in a library application. The Scheduler methods parse String objects into Date Time objects. You write a console application named Coverage.exe to test each method in Scheduler. You want Coverage.exe to test Scheduler for multiple cultures to verify its globalization support. What should you do?
A. Create a CultureInfo object for each culture locale before calling the TestKScheduler methods.
B. Create a RegionInfo object for each culture locale before calling the TestKScheduler methods.
C. Set the current thread’s CurrentCulture property to each culture locale before calling the TestKScheduler methods.
D. Create a Coverage.exe.config file and add a <location> element to the configuration file for each culture locale.
ANSWER : C


You have an ASP.NET application named TKWebApp. This application uses a private assembly named Employee to store and retrieve employee data. Employee is located in the bin directory of TKWebApp. You develop a new ASP.NET application named TKWebApp2 that also needs to use Employee. You assign Employee a strong name, set its version to 1.0.0.0, and install it in the global assembly cache. You then create a publisher policy assembly for version 1.0.0.0 and install it in the global assembly cache. You compile TKWebApp2 against version 1.0.0.0. You do not recompile MyWebApp. You then run TKWebApp. What is the most likely result?
A. A VersionNotFoundException is thrown.
B. Employee is loaded from the bin directory.
C. Version 1.0.0.0 of Employee is loaded from the global assembly cache.
D. Version 1.0.0.0 of Employee is loaded by the publisher policy assembly.
ANSWER : D


You are creating a Windows-based application named TKWinApp. To the application, you add a Windows Form named TKForm and a reference to a SingleCall .NET Remoting object named TheirObject. You need to ensure that TKForm creates an instance of TheirObject to make the necessary remote object calls. Which code segment should you use?
A. RemotingConfiguration.RegisterActivatedClientType(typeof(TheirObject),“http://GsoftServer/TheirAppPath/TheirObject.rem”);
    TheirObject theirObject = new TheirObject();
B. RemotingConfiguration.RegisterWellKnownClientType(typeof(GsoftObject);“http://GsoftServer/TheirAppPath/TheirObject.rem”);
    TheirObject theirObject = new TheirObject();
C. RemotingConfiguration.RegisterActivatedServiceType(typeof(TheirObject));
    TheirObject theirObject = new TheirObject();
D. RemotingConfiguration.RegisterWellKnownServiceType(typeof(TheirObject),“http://GsoftServer/TheirAppPath/TheirObject.rem”,WellKnownObjectMode.Singleton);
    TheirObject theirObject = new TheirObject();
ANSWER : B


You create an XML Web service project that consists of three services named BronzeService, SilverService, and GoldService. All three services are located in the same virtual directory on a production computer. When customers subscribe to your service, they select only one of the three available services. A new customer subscribes to SilverService. You need to create a discovery document that enables this customer to use only SilverService. Which discovery document should you create?
A. <disco:discovery
     xmlns:disco=”http://schemas.xmlsoap.org/disco/”
     xmlns:scl=http://schemas.xmlsoap.org/disco/scl/>
     <scl:contractRef ref=”SilverService.asmx?wsdl” />
     </disco:discovery>
B. <disco:discovery
     xmlns:disco=”http://schemas.xmlsoap.org/disco/”
     xmlns:scl=”http://schemas.xmlsoap.org/disco/scl/”>
     <scl:contractRef ref=”SilverService.asmx” />
     </disco:discovery>
C. <dynamicDiscovery xmlns=”urn:schemasdynamicdiscovery:
     disco.2000-03-17”>
     <exclude path=”_vti_cnf” />
     <exclude path=”_vti_pvt” />
     <exclude path=”_vti_log” />
     <exclude path=”_vti_script” />
     <exclude path=”_vti_txt” />
     <exclude path=”Web References” />
     </dynamicDiscovery>
D. <dynamicDiscovery xmlns=”urn:schemasdynamicdiscovery:
     disco.2000-03-17”>
     <exclude path=”_vti_cnf” />
     <exclude path=”_vti_pvt” />
     <exclude path=”_vti_log” />
     <exclude path=”_vti_script” />
     <exclude path=”_vti_txt” />
     <exclude path=”Web References” />
     <exclude path=”BronzeService.asmx” />
     <exclude path=”GoldService.asmx” />
     </dynamicDiscovery>
ANSWER : A


You create version 1.0.0.0 of an assembly named TestKiAssembly. You register the assembly in the global assembly cache. TestKiAssembly consists of two .NET Remoting objects named TKRemoteObject1 and TKRempoteObject2 These objects are configured in the App.config file of TestKiAssembly as shown in the following code segment:
<system.runtime.remoting>
<application>
<service>
<activated type=”TestKiAssembly.TKRemoteObject1,
TestKiAssembly, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=28dckd83491duj” />
<wellKnown mode=”SingleCall”
objectUri=”TKRemoteObject2.rem”
type=”TestKiAssembly.TKRemoteObject2, TestKiAssembly,
Version=1.0.0.0, Culture=neutral,
PublicKeyToken=28dckd83491duj” />
<channels>
<channel ref=”http” />
</channels>
</service>
</application>
</system.runtime.remoting>
You create an application named TKApp that resides on a different computer than TestKiAssembly. TKApp references version 1.0.0.0 of TestKiAssembly. TKApp contains code that activates instances of TKRemoteObject1 and TKRemoteObject2 to use their services. Due to changes in business needs, you must update TestKiAssembly. You create version 2.0.0.0 of TestKiAssembly, which is backward compatible, but you do not update any information in the App.config file of TestKiAssembly. You register version 2.0.0.0 of TestKiAssembly in the global assembly cache. You then rebuild TKApp. Which version of the remote object will MyApp activate?
A. Version 1.0.0.0 of TKRemoteObject1; version 1.0.0.0 of TKRemoteObject2.
B. Version 1.0.0.0 of TKRemoteObject1; version 2.0.0.0 of TKRemoteObject2.
C. Version 2.0.0.0 of TKRemoteObject1; version 1.0.0.0 of TKRemoteObject2.
D. Version 2.0.0.0 of TKRemoteObject1; version 2.0.0.0 of TKRemoteObject2.
ANSWER : B


You are creating an XML Web service named InventoryService for a Gsoft Ltd. Each branch of Gsoft Ltd. will build its own client application to consume InventoryService. Each branch connects to the main office of the dealership by using a virtual private network (VPN). All computers in the dealership run on Microsoft Windows operating systems. You need to ensure that callers of InventoryService are authenticated based on their Windows logon name and password. You configure Internet Information Services (IIS) according to your security needs. You need to configure the authentication type in the Web.config file. Which code segment should you use?
A. <authentication mode=”Basic” />
B. <authentication mode=”Forms” />
C. <authentication mode=”Integrated” />
D. <authentication mode=”Windows” />
ANSWER : D


You are preparing to deploy an XML Web service named GsoftInventoryService. This service queries a Microsoft SQL Server database and returns information to the caller. You use Visual Studio .NET to create a setup project. You need to install InventoryService. You also need to run a script to create the necessary SQL Server database and tables to store the data. To accomplish this, you need to configure the project to have administrator rights to the SQL Server database. You add a custom dialog box to the project that prompts the user for the administrator user name and password that are used to connect to the SQL Server database. You need to make the user name and password available to a custom Installer class that will execute the script. What should you do?
A. Add a launch condition that passed the user name and password to the Install subroutine.
B. Add a merge module to the project that captures the user name and password. Use the merge module to access these values in the Install subroutine.
C. Retrieve the user name and password from the savedState object in the Install subroutine.
D. Create a custom install action. Set the CustomActionData property to the entered user name and password. Then access these values in the Install subroutine.
ANSWER : D


You create a Windows service that processes XML messages placed in a MSMQ queue. You discover that the service is not functioning properly. You need to debug the service to correct the program. What should you do?
A. Start the Windows service. Then attach a debugger to the process.
B. Attach a debugger to the Windows service. Then start the Windows service.
C. Start the Windows service. Then run the .NET Services Installation tool (Regsvcs.exe).
D. Place a breakpoint in the Main method of the Windows service. Then run the application within the Visual Studio .NET integrated development environment (IDE).
ANSWER : A


You create a .NET Remoting object named Time. The Time is in the Utils namespace and is in an assembly file named Gsoft.dll. The Time class is hosted in an Internet Information Services (IIS) virtual directory named UtilsSvr. The Time class is configured to be a server-activated object and uses a URI named Time.rem. You use a client application named TestK.exe to test the Time object. TestK.exe creates instances of the Time object by using the following method signature:
public Time CreateInstance() {
RemotingConfiguration.Configure(“TestK.exe.config”);
return new Time();
}
You want Gsoft.exe to create instances of the Time class on a compute named Hosting. What should you do?
A. Create a TestK.exe.config file that includes the following code segment:
    <configuration> <system.runtime.remoting>
    <application> <client>
    <wellKnown
    type=”Utils.Time, Gsoft”
    url=”tcp://Hosting:80/UtilsSvr/Time.rem”/>
    </client> </application>
    </system.runtime.remoting> </configuration>
B. Create a TestK.exe.config file that includes the following code segment:
    <configuration> <system.runtime.remoting>
    <application> <client>
    <wellKnown
    type=”Utils.Time, Gsoft”
    url=”http://Hosting/UtilsSvr/Time.rem”/>
    </client> </application>
    </system.runtime.remoting> </configuration>
C. Create a TestK.exe.config file that includes the following code segment:
    <configuration> <system.runtime.remoting>
    <application>
    <client url=”http://Hosting/UtilsSvr/Time.rem”>
    <activated
    type=”Utils.Time, Gsoft”/>
    <client> </application>
    </system.runtime.remoting> </configuration>
D. Create a TestK.exe.config file that includes the following code segment:
    <configuration> <system.runtime.remoting>
    <application>
    <client url=”tcp://Hosting:80/UtilsSvr/Time.rem”>
    <activated
     type=”Utils.Time, Gsoft”/>
    </client> </application>
    </system.runtime.remoting> </configuration>
ANSWER : B


You are creating an XML Web service that processes highly confidential messages. The service exposed a Web method named RetrieveMessage that takes as input a code name and returns an encrypted message. You create a SOAP extension and override the extension’s ProcessMessage method so that you can encrypt the message before it is sent back to the caller. You need to encrypt only the data within the RetrieveMessageResult node of the SOAP response. You create a function named EncryptMessage that encrypts the RetrieveMessageResult node. You need to ensure that this method gets called before sending the message back to the caller. During which SoapMessageStage should you call EncryptMessage?
A. BeforeSerialize
B. AfterSerialize
C. BeforeDeserialize
D. AfterDeserialize
ANSWER : B


You are developing an application named TestKApp by using Visual C# .NET and Visual Basic .NET. The application will use functions form a DLL written in unmanaged code. One function requires the calling application to allocate unmanaged memory, fill it with data, and pass the address of the memory to the function. On returning from the function, the calling application must deallocate the unmanaged memory. You need to decide how your application will handle unmanaged memory. What should you do?
A. Use a byte array.
B. Use the methods of the Marshal class.
C. Use the methods of the MemoryStream class.
D. Derive a new class from the Stream class, and override the allocation methods.
ANSWER : B


You are using Visual Studio .NET to develop an application to replace a COM-based application. You are assigned to write a .NET class that will be used by client applications as a COM object. Your class code is being moved and modified while development continues on the new application. You want to minimize any possible disruption to the COM interface as a result of code changes. Which code segment should you use?
A. [ClassInterface()]
     public Class TKClassToExpose {
     public int Calc() {
    // Implementation code goes here.
    }
    }
B. [Guid(“9ED54F84-A89D-4fcd-A854-44251E925F09”)]
     public interface ITKClassToExpose {
     public int Calc();
     }
    [ClassInterface[ClassInterfaceType.None)]
    public int Calc() {
    // Implementation code goes here.
    }
    }
C. [Guid(“9ED54F84-A89D-4fcd-A854-44251E925F09”)]
     [ComVisible(true)]
     public class TKClassToExpose {
     public int Calc() {
     // Implementation code goes here.
     }
     }
D. [ClassInterface(ClassInterfaceType.AutoDispatch)]
     public class TKClassToExpose {
     public int Calc() {
     // Implementation code goes here.
     }
     }
ANSWER : D


You are creating an ASP.NET application named TestKWebApp. To TestKWebApp, you add a Web reference to an XML Web service named UserService. UserService consists of a Web method named RetrieveUserInfo. This Web method takes a userID as input and returns a DataSet object containing user information. If the userID is not between the values 1 and 1000, a System ArgumentException is thrown. In TestKWebApp, you write a try/catch block to capture any exceptions that are thrown by UserService. You invoke RetrieveUserInfo and pass 1001 as the user ID. Which type of exception will be caught?
A. System.ApplicationException
B. System.ArgumentException
C. System.Web.Service.Protocols.SoapException
D. System.Web.Service.Protocols.SoapHeaderException
ANSWER : C


You are developing a Windows-based application that requires the use of a calculation function named CalculateValue. This function includes the following signature:
int CalculateValue(int x) ;
CalculateValue is located in an unmanaged DLL named GsoftFunctions.dll, and is not part of a COM interface. You need to be able to use CalculateValue in your application. Which action or actions should you take? (Choose all that apply)
A. Use Regsvr32.exe to register GsoftFunctions.dll.
B. Use Visual Studio .NET to add a reference to GsoftFunctions.dll.
C. To your application, add the following code segment:
     using GsoftFunctions;
D. To your application, add the following code segment:
     [DllImport(“GsoftFunctions.dll”)]
     public static extern int CalculateValue(int x);
ANSWER : B, D


You are creating a .NET Remoting object named Dealer for automobile dealership. Dealer exposes a method named SaveGsoftSales that saves sales information for the dealership. Dealer is configured to use Integrated Windows authentication to authenticate its callers. You must ensure that all users of SaveGsoftSales are members of the Manager group before allowing the code within SaveGsoftSales to run. Which code segment should you use?
A. [PrincipalPermission(SecurityAction.Demand, Role=”Manager”)]
     public DataSet SaveGsoftSales(DataSet sales) {
     // Code to save sales data goes here.}
B. [PrincipalPermission(SecurityAction.LinkDemand, Role=Manager”)]
     public DataSet SaveGsoftSales(DataSet sales) {
     // Code to save sales data goes here.}
C. [PrincipalPermission(SecurityAction.InheritanceDemand, Role=”Manager”)]
     public DataSet SaveGsoftSales(DataSet sales) {
     // Code to save sales data goes here.}
D. public DataSet SaveGsoftSales(DataSet sales) {
     string role = “Manager”;
     PrincipalPermission perm = new PrincipalPermission(null, role);
     // Code to save sales data goes here.}
ANSWER : A


You create three Windows services named TK1, TK2, and TK3. You want to install all three services on a computer named GsoftA by using the Installer tool (Installutil.exe). On the command line of GsoftA, you enter and run the following command: Installutil TK1 TK2 TK3 During the installation process, TK3 throws an installation error. The installation process completes. How many of the three services are now installed on GsoftA?
A. None
B. One
C. Two
D. Three
ANSWER : A


You create two serviced components named OrderPipeline and OrderAdmin. Each component is registered in a separate COM+ server application. Both components use pricing data. OrderPipeline reads the pricing data for placing user orders. OrderAdmin modifies the pricing data. You want to ensure that OrderPipeline accesses the pricing data as quickly as possible, while still being able to immediately retrieve any pricing changes made by OrderAdmin. What should you do?
A. Store the pricing data in the Shared Property Manager.
B. Store the pricing data in Microsoft SQL Server database.
C. Store the pricing data in a Hashtable object within OrderAdmin. Expose the Hashtable object through a property on OrderAdmin.
D. Store the pricing data in an XmlDocument object within OrderAdmin. Expose the XmlDocument object through a property on OrderAdmin.
ANSWER : C


You have a .NET Remoting object named Utils. The Utils class is a client-activated .NET Remoting object. You want to write a client application that creates and uses a Utils object. You want the client application to hold onto a reference to a Utils object for the duration of its execution. What should you do?
A. Construct the Utils object, and hold the object in a member variable.
B. Construct the Utils object, and set the LifeTimeService.LeaseTime to 0.
C. In the client application, create an Implementation of the ISponsor interface. Implement the Renewal method to extend the lease.
D. In the client application, create an Implementation of the ILease interface. Implement the CurrentLeaseTime property to return Int32.MaxValue.
ANSWER : C


You are creating a serviced component named UserManager. UserManager adds user accounts to multiple transactional data sources. The UserManager class includes the following code segment:
[Transaction(TransactionOption.Required)]
[SecurityRole(“Admin”)]
public class UserManager : ServicedComponent {
public void AddUser(string TestKname, string TestKpassword)
{
// Code to add the user to data sources goes here.
}
}
You must ensure that the AddUser method reliably saves the new user to either all data sources or no data sources. What should you do?
A. To AddUser, add the following attribute:
     [AutoComplete()]
B. To UserManager, add the following attribute:
     [JustInTimeActivation(false)]
C. To the end of AddUser, add the following line of code:
     ContextUtil.EnableCommit();
D. To the end of AddUser, add the following line of code:
     ContextUtil.MyTransactionVote = true;
ANSWER : C


You create a serviced component named Tracker that uses attributes to dynamically register itself for COM+ services. Tracker is in an assembly file named Gsoft.dll. Tracker uses transactions and role-based security. The roles and the application identity for Tracker are configured on the development computer. You are preparing to hand off Tracker to and administrator for deployment to production computers. You want all the COM+ configuration information for Tracker to be installed on the production computers. What should you do?
A. Use the Component Services tool to export Tracker to an .msi file. Provide to the administrator the .msi file with instructions to run the installer.
B. Provide to the administrator the Gsoft.dll file. Instruct the administrator to copy Gsoft.dll to all production computers and to install it in the global assembly cache.
C. Provide to the administrator the Gsoft.dll file. Instruct the administrator to use the .NET Services Installation tool (Regsvcs.exe) to install Tracker.
D. Add a new merge module to your solution. Add Gsoft.dll to the merge module. Provide to the administrator the .msm file with installation instructions.
ANSWER : A


You are creating an XML Web service that provides a daily quotation from literary works to its customers. This quotation is requested in many different languages, thousands of times every day, and by thousands of Web sites operating many different platform. A Web method named GetGsoftQuotes takes a languageID as input. GetGsoftQuotes uses this language ID to retrieve a translated version of the daily quotation from a Microsoft SQL Server database and to return that quotation to the customer. You want to minimize the time it takes to return the translated version. What should you do?
A. Store each translated quotation by using the Cache object.
B. Store each translated quotation by using the Session object.
C. Set the BufferResponse property of the WebMethod attribute to false.
D. Set the CacheDuration property of the WebMethod attribute to an interval greater than zero.
ANSWER : A


You are creating a .NET Remoting object named PropertyCache. PropertyCache will hold a Hashtable object or name/value pairs. A variety of remote client applications will communicate with PropertyCache to set and get property values. You need to ensure that properties set by one client application are also accessible to other client applications. Which two actions should you take? (Each correct answer presents part of the solution. Choose two)
A. Configure PropertyCache to be a client-activated object.
B. Configure PropertyCache to be a server-activated Singleton object.
C. Configure PropertyCache to be a server-activated SingleCall object.
D. Derive the PropertyCache class from MarshalByRefObject and override InitializeLifetimeService() to return null.
E. Mark the PropertyCache class with the Serializable attribute. Implement the ISponsor interface in the PropertyCache class.
F. Implement the ISerializable and ILease interfaces in the PropertyCache class. Implement ILease.CurrentLeaseTime to return Int32.MaxValue.
ANSWER : B, E


You create a .NET Remoting object named Patientinfo that exposes medical patient information. Because of the confidential nature of the information, you must ensure that the data remains secure. You want client applications to connect to Patientinfo over a secure communication channel. You want to accomplish this task by writing the minimum amount of code. What should you do?
A. Create your own host application and use a TcpChannel and BinaryFormatter.
B. Create your own host application and use an HttpChannel and a SoapFormatter.
C. Install Patientinfo in an Internet Information Services (IIS) virtual directory. Configure Patientinfo to use a TcpChannel and a BinaryFormatter. Configure IIS to use SSL.
D. Install Patientinfo in an Internet Information Services (IIS) virtual directory. Configure Patientinfo to use an HttpChannel and a SoapFormatter. Configure IIS to use SSL.
ANSWER : D


You create an XML Web service named AutoPartsService that processes automobile part orders. This service exposes a Web method named PlaceTestKOrder, which is shown in the following code segment:
[WebMethod(TransactionOption.RequiresNew)]
public DataSet PlaceTestKOrder(DataSet orderData) {
Server1.BrakesService brakes = new
Server1.BrakesService();
Server2.PartsService parts = new Server2.PartsService();
// Call OrderBrakes to order only brakes.
brakes.OrderBrakes(orderData.Tables[“Brakes”]);
// Call OrderParts to order all other auto parts.
parts.OrderParts(orderData.Tables[“Parts”]);
}
BrakesService and PartsService are XML services. The TransactionOption property of OrderBrakes and OrderParts is set to TransactionOption.Required. You develop a Windows Forms application named TKPartOrderApp that consumes AutoPartsService. You run TKPartOrderApp and place and order for three sets of brakes and four wheels. While PlaceTestKOrder is placing the order for the wheels, you close TKPartOrderApp. What is the most likely result?
A. OrderParts stops processing the order, and all orders are cancelled.
B. OrderParts continues processing the order, and all orders are placed.
C. OrderParts stops processing the order, the brakes are ordered, but the wheels are not ordered.
D. OrderParts stops processing the order, the brakes are not ordered, but the wheels are ordered.
ANSWER : A


You create a serviced component named StockQuote that implements the IStockQuote interface. The StockQuote class includes the following code segment:
public class StockQuote : ServicedComponent, IStockQuote {
public Price GetQuote(Ticker stock) {
// Code for the method goes here.
}
}
You want to secure StockQuote so that it can only be accessed by users in the Customers and Managers roles. Which two actions should you take? (Each correct answer presents part of the solution. Choose to)
A. To the StockQuote class, add the following attribute:
     [ComponentAccessControl]
B. To the StockQuote class, add the following attribute:
     [Transaction(TransactionOption.Required)]
C. Implement the ISecurityCallContext COM interface in the StockQuote class.
     Implement the IsCallerInRole method for the Customers and Managers roles.
D. To the StockQuote class, ad the following attributes:
     [SecurityRole(“Customers”, false)]
     [SecurityRole(“Managers”, false)]
E. To the beginning of the GetQuote method, add the following code segment:
     if (!ContextUtil.IsCallerInRole(“Managers,Customers”)) {
     throw new SecurityException(“Access is denied.”);
     }
ANSWER : A, D


You are creating an XML Web service named myService. This service has a function named WriteMessage that writes messages to a flat file in the C:\TestKingLogs\myServiceLog directory. You want to implement security for WriteMessage so that WriteMessage and all the code it calls can write messages only to the myServiceLog directory. Which code segment should you use?
A. FileIOPermission filePermission = new FileIOPermission(FileIOPermissionAccess.Write,“C:\\TestKingLogs\myServiceLog”);
     filePermission.Demand();
B. FileIOPermission filePermission = new FileIOPermission(FileIOPermissionAccess.Write,“C:\\TestKingLogs\myServiceLog”);
     filePermission.Deny();
C. FileIOPermission filePermission = new FileIOPermission(FileIOPermissionAccess.Write,“C:\\TestKingLogs\myServiceLog”);
     filePermission.PermitOnly();
D. FileIOPermission filePermission = new FileIOPermission(FileIOPermissionAccess.Write,“C:\\TestKingLogs\myServiceLog”);
     filePermission.Assert();
ANSWER : C


You create an assembly that contains a collection of serviced components. You want to secure these components by using a collection of COM+ roles. Different groups of roles will secure different components. You need to ensure that role-based security is enforced in the assembly. You want to accomplish this goal by adding an attribute to the project source code. Which attribute should you use?
A. [assembly: SecurityRole(“Assembly”, true)]
B. [assembly:SecurityPermission(SecurityAction.RequestOptional)]
C. [assembly:ApplicationActivation(ActivationOption.Server)]
D. [assembly: ApplicationAccessControl(AccessChecksLevel =AccessChecksLevelOption.ApplicationComponent)]
ANSWER : C


You have a DataSet object named customersDataSet that contains a DataTable object named TestKCustomers. TestKCustomers retrieves information from a Microsoft SQL Server database. TestKCustomers contains a column named Region. You want to create a DataView object named customersDataView that contains only customers in which the value in the Region column is France. Which code segment should you use?
A. DataView customersDataView = new DataView(customersDataSet.Tables[“TestKCustomers”]);
     customersDataView.FindRows(“Region = France”);
B. DataView customersDataView = new DataView(customersDataSet.Tables[“TestKCustomers”]);
     customersDataView.FindRows(“Region = ‘France’”);
C. DataView customersDataView = new DataView(customersDataSet.Tables[“TestKCustomers”]);
     customersDataView.RowFilter = (“Region = France”);
D. DataView customersDataView = new DataView(customersDataSet.Tables[“TestKCustomers”]);
     customersDataView.RowFilter= (“Region = ‘France’”);
ANSWER : D


You are troubleshooting a Visual Studio .NET application that was developed by a former colleague. You find the following code segment within a large assembly:
XmlElement theElement;
XmlElement anotherElement;
XmlDocument doc = new XmlDocument();
XmlDeclaration theDecl =doc.AppendChild(theDecl);
theElement = doc.CreateElement(“Library”);
doc.AppendChild(theElement);
theElement = doc.CreateElement(“Book”);
theElement.SetAttribute(“type”,”Certification”);
anotherElement = doc.CreateElement(“TestKing 70-216 Q&A”);
anotherElement.InnerText = “Book Title”;
anotherElement.AppendChild(theElement);
doc.DocumentElement.AppendChild(theElement);
Which XML output is produced by this code segment?
A. <?xml version=”1.0”?>
     <Library />
B. <?xml version=”1.0?>
     <Library>
    <Book type=” Certification” />
    </Library>
C. <?xml version=”1.0”?>
     <Library>
     <Book type=” Certification”>
     <Title> TestKing 70-216 Q&A </Title>
     </Book>
     </Library>
D. <?xml version=”1.0”?>
     <Library>
     <Title> TestKing 70-216 Q&A <Book type=”Certification”
      /></Title>
      <Library>
ANSWER : B


You have a DataSet object named loanCustomersDataSet that contains customers serviced by the loan department of TestKink Inc. You receive a second DataSet object named assetCustomersDataSet that contains customers serviced by the asset management department of your company. Both objects have the same structure. You want to merge assetCustomersDataSet into loanCustomersDataSet and preserve the original values in loanCustomersDataSet. Which code segment should you use?
A. loanCustomersDataSet.Merge(assetCustomersDataSet);
B. loanCustomersDataSet.Merge(assetCustomersDataSet, true);
C. assetCustomersDataSet.Merge(loanCustomersDataSet);
D. assetCustomersDataSet.Merge(loanCustomersDataSet, true);
ANSWER : B


You are developing an application that queries a table named Products in a Microsoft SQL Server database named TestKingData. The query will be stored in a string variable named sqlQuery. The query includes the following SQL code:
SELECT * FROM Products FOR XML AUTO
You must iterate the query results and populate an HTML table with product information.You must ensure that your application processes the results as quickly as possible.What should you do?
A. Use a SqlDataAdapter object and set its SelectCommand property to sqlQuery.
     Use the Fill method of the SqlDataAdapter object to read the data into a DataSet object.
     Loop through the associated rows to read the data.
B. Use a SqlDataAdapter object and set its SelectCommand property to sqlQuery.
     Use the Fill method of the SqlDataAdapter object to read the data into a DataSet object.
     Use the ReadXml method of the DataSet object to read the data.
C. Set the SqlCommand object’s CommandText to sqlQuery.
     Use the ExecuteReader method of the SqlCommand object to create a SqlDataReader object.
     Use the Read method of the SqlDataReader object to read the data.
D. Set the SqlCommand object’s CommandText to sqlQuery.
     Use the ExecuteXmlReader method of the SqlCommand object to create an XmlReader object.
     Use the XmlReader object to read the data.
ANSWER : D


You are developing an application that retrieves a list of geographical regions from a table in a Microsoft SQL Server database. The list of regions is displayed in a dropdown list box on a Windows Form. You want to populate the list box with data from a DataSet object. You want to fill the DataSet object by using a SqlDataAdapter object. You create a SqlConnection object named TKConnection and a SQL query string named regionSQL. You need to write the code to create the SqlDataAdapter object. Which code segment should you use?
A. SqlDataAdapter TKDataAdapter = new SqlDataAdapter();
     TKDataAdapter.SelectCommand.Connection = TKConnection;
     TKDataAdapter.SelectCommand.CommandText = regionSQL;
B. SqlDataAdapter TKDataAdapter = new
     SqlDataAdapter(regionSQL, TKConnection);
C. SqlCommand SqlCmd = new SqlCommand(regionSQL);
     SqlDataAdapter TKDataAdapter = new SqlDataAdapter();
     TKDataAdapter.SelectCommand.Connection= TKConnection;
     TKDataAdapter.SelectCommand = SqlCmd;
D. SqlCommand SqlCmd = new SqlCommand();
     SqlDataAdapter TKDataAdapter = new SqlDataAdapter();
     SqlCmd.CommandText = regionSQL;
     TKDataAdapter.SelectCommand.Connection= TKConnection;
ANSWER : B


Your Microsoft SQL Server 6.5 database contains a table named TestKPurchaseOrders that consists of more than 1 million rows. You are developing an application to populate a DataReader object with data from TestKPurchaseOrders. You want to ensure that the application processes the data as quickly as possible. You create a SQL SELECT statement in a local variable named TKSQLSelect. You need to instantiate a SqlConnection object and a SqlCommand object that you will use to populate the DataReader object. Which code segment should you use?
A. OleDbConnection myConnection = new OleDbConnection(myOleDbConnectionString);
     OleDbCommand TKCommand = new OleDbCommand(TKSQLSelect);
B. OleDbConnection TKConnection = new OleDbConnection(TKOleDbConnectionString);
     OleDbCommand TKCommand = new OleDbCommand(TKSQLSelect, TKConnection);
C. SqlConnection TKConnection = new SqlConnection(TKSqlConnectionString);
     SqlCommand TKCommand = new SqlCommand(TKSQLSelect);
D. SqlConnection TKConnection = new SqlConnection(TKSqlConnectionString);
     SqlCommand TKCommand = new SqlCommand(TKSQLSelect, TKConnection);
ANSWER : B


You have a DataSet object that contains a single DataTable object named TestKEmployees. TestKEmployees has a column named EmployeeID. EmployeeID contains no duplicate data. You are creating a function that accepts a parameter of EmployeeID and searches Employees to return the DataRow object for the specified EmployeeID. You want to use the Find method of the rows collection in Employees to return the requested DataRow object from the function. You need to ensure that you can use the Find method to accomplish this goal. What should you do?
A. Ensure that EmployeeID is the first column in TestKEmployees.
B. Ensure that EmployeeID is unique for each row in TestKEmployees.
C. Ensure that TestKEmployees has a primary key on EmployeeID.
D. Ensure that TestKEmployees is sorted in ascending order on EmployeeID.
ANSWER : C


You have a SqlDataReader object named TKproductsDataReader. The productsDataReader object contains three columns in the following order:
• ProductID as Integer
• ProductName as nvarchar(40)
• UnitsInStock as Integer
You want to use TKproductsDataReader to create an inventory management report.You define the following three variables:
• int myProductID;
• string myProductName;
• int myUnits;
You need to ensure that the report runs as quickly as possible.Which code segment should you use?
A. myProductID = (int) TKproductsDataReader[1];
myProductName = (string) TKproductsDataReader[2];
myUnits = (int) TKproductsDataReader[3];
B. myProductID = (int) TKproductsDataReader[0];
myProductName = (string) TKproductsDataReader[1];
myUnits = (int) TKproductsDataReader[2];
C. myProductID = (int) TKproductsDataReader[“ProductID”];
myProductName = (string)
TKproductsDataReader[“ProductName”];
myUnits = (int) TKproductsDataReader[“UnitsInStock”];
D. myProductID = (int)
TKproductsDataReader.GetOrdinal(“ProductID”);
myProductName = (string)
TKproductsDataReader.GetOrdinal(“ProductName”);
myUnits = (int)
TKproductsDataReader.GetOrdinal(“UnitsInStock”);
ANSWER : B


TestKing Ltd. receives product information from manufactures in the form of an XML documents. The product information is stored in a Microsoft SQL Server database. The format of each XML document varies. Each one is located in a MemoryStream object named newProds. You create a merge procedure that reads data and schema information in a DataSet object and merges the information into your database. You now need to write code to transfer the XML document and its schema into a DataSet object. Which code segment should you use?
A. DataSet products = new DataSet(“prodInfo”);
XmlTextReader reader = new XmlTextReader(newProds);
XmlValidatingReader validReader = new
XmlValidatingReader(reader);
while (validReader.Read()) {
products.WriteXml(validReader.Value);
}
B. DataSet products = new DataSet(“prodInfo”);
products.ReadXml(newProds);
C. DataSet products = new DataSet(“prodInfo”);
XmlDataDocument document =
new XmlDataDocument(products);
document.DataSet.ReadXmlSchema(newProds);
D. DataSet products = new DataSet(“prodInfo”);
string myXmlData =
Encoding.UTF8.GetString(newProds.ToArrary());
SqlDataAdapter adapter =
new SqlDataAdapter(“LoadSchemaType=XML”,myXmlData);
adapter.Fill(products)
ANSWER : B


Your Microsoft SQL Server database has a stored procedure named GetCompanyName. Ge accepts one parameter named @CustomerID and returns the appropriate company name. You instantiate a SqlCommand object named TKCommand. You need to initialize TKCommand to return the company name for @CustomerID with a value of “ALFKI”. Which code segment should you use?
A. TKCommand.CommandText = “GetCompanyName, ALFKI”;
TKCommand.Parameters.Add(“@CustomerID”);
B. TKCommand.CommandText = “GetCompanyName”;
TKCommand.Parameters.Add(“GetCompanyName”, “ALFKI”);
C. TKCommand.CommandText = “@CustomerID”;
TKCommand.Parameters.Add(“GetCompanyName”, “ALFKI”);
D. TKCommand.CommandText = “GetCompanyName”;
TKCommand.Parameters.Add(“@CustomerID”, “ALFKI”);
ANSWER : D


You are developing an application to monitor store inventory. When inventory falls below a specified level, the application automatically generates a purchase request. Suppliers have requested that you transmit purchase requests to them in an XML document. Suppliers will accept the XML document in any valid form, except they do not want the data set definition to be included in the XML file. You create a method named GeneratePurchaseRequest. You write the code to populate a DataSet object named myDataSet with the purchase request data. You define a variable named fileName that contains the name and path of the output file. You need to create an XML file from the data in myDataSet by adding code to GeneratePurchaseRequest. You want to accomplish this task by writing the minimum amount of code. Which code segment should you use?
A. myDataSet.WriteXML(fileName, XmlWriteMode.IgnoreSchema);
B. myDataSet.WriteXML(fileName, XmlWriteMode.WriteSchema);
C. myDataSet.WriteXMLSchema(filename);
D. TextWriter myWriter = new StreamWriter(fileName);
     myDataSet.WriteXMLSchema(myWriter);
ANSWER : A


You have a DataSet object named TKDataSet that is populated with data from a Microsoft SQL Server database. This object contains insertions, deletions, and updates to the data. You want to apply the data changes in TKDataSet to the database. You decide to use the SqlClient data provider. You need to create a data object that you will use to update the database. Which code segment should you use?
A. SqlDataReader myDataReader;
B. SqlDataAdapter mySqlDataAdapter = new sqlDataAdapter();
C. DataObject myDataObject = new DataObject();
D. SqlParameter myParameter = new SqlParameter();
ANSWER : B


You are planning to create a DataSet object named TKDataSet to be used in a bondtrading application. Several developers will need to write code to manipulate myDataSet, and you want to ensure that TKDataSet is easy for them to use. You decide to create TKDataSet as a strongly typed data set. Which two actions should you take? (Each correct answer presents part of the solution. Choose two)
A. Create an XSD schema that defines TKDataSet.
B. Create an XDR schema that defines TKDataSet.
C. Create a class for TKDataSet that is based on the schema and that inherits from the DataSet class.
D. Create a class for TKDataSet that is based on the schema and that inherits from the XmlSchema class.
E. Create a key pair for TKDataSet by using the Strong Name tool (Sn.exe).
ANSWER : A, C


You develop an ADO.NET application that uses a Microsoft SQL Server database and a SqlClient data provider. Your application includes the following four code segments, which are each called once:
SqlConnection myConnection1 = new SqlConnection();
myConnection1.ConnectionString = “Data Source=TestKServer;”
+ “Initial Catalog=Billing;Integrated Security=true”;
myConnection1.Open();
SqlConnection myConnection2 = new SqlConnection();
myConnection2.ConnectionString = “Data Source=TestKServer;”
+ “Initial Catalog=Billing;Integrated Security=True”;
myConnection2.Open();
SqlConnection myConnection3 = new SqlConnection();
myConnection3.ConnectionString=
“Data Source=TestKingServerB;”
+ “Initial Catalog=Search;Integrated Security=true”;
myConnection3.Open();
SqlConnection myConnection4 = new SqlConnection();
myConnection4.ConnectionString = “Data Source=TestKServer;”
+ “Initial Catalog=OrderEntry;Integrated Security=true”;
myConnection4.Open();
You verify that your application is the only application that is using SQL Server. Your application runs all code segments by using the same identity. You run the application. Connection pooling is enabled, and the entire application runs within the connection timeout parameter. How many connection pools are created?
A. One
B. Two
C. Three
D. Four
ANSWER : C


You have a SqlDataReader object named ordersDataReader. This object contains a column named OrderQuantity that has an integer value. This object also contains one row for each order received during the previous week. You need to write code that will process each row in ordersDataReader and pass OrderQuantity to a function named myFunction. Which code segment should you use?
A. long weeklyOrderQuantity = 0;
while (ordersDataReader.Read()) {
myFunction((int)ordersDataReader[“OrderQuantity”]);
}
B. long weeklyOrderQuantity = 0;
while (ordersDataReader.NextResult()) {
myFunction((int)ordersDataReader[“OrderQuantity”]);
}
C. long weeklyOrderQuantity = 0;
int orderCount = 0;
while (orderCount < ordersDataReader.FieldCount) {
myFunction((int)ordersDataReader[“OrderQuantity”]);
orderCount++;
ordersDataReader.Read();
}
D. long weeklyOrderQuantity = 0;
int orderCount = 0;
while (orderCount < ordersDataReader.FieldCount) {
myFunction((int)ordersDataReader[“OrderQuantity”]);
orderCount++;
ordersDataReader.NextResult();
}
ANSWER : A

MCQ: XML

What does XML stand for?
A. eXtra Modern Link
B. eXtensible Markup Language
C. Example Markup Language
D. X-Markup Language
ANSWER : B


What is the correct syntax of the declaration which defines the XML version?:
A. <xml version="1.0" />
B. <?xml version="1.0"?>
C. <?xml version="1.0" />
D. None of the above
ANSWER : B


Is it easier to process XML than HTML?
A. Yes
B. No
C. Somtimes
D. Cant say
ANSWER : A

Which of the following programs support XML or XML applications?:
A. Internet Explorer 5.5
B. Netscape 4.7
C. RealPlayer.
D. both 1 and 2
ANSWER : D

Kind of Parsers are
A. well-formed
B. well-documented
C. non-validating and validating
D. none of the above
ANSWER : C

Well formed XML document means
A. it contains a root element
B. it contain an element
C. it contains one or more elements
D. must contain one or more elements and root element must contain all other elements
ANSWER : D

Comment in XML document is given by
A. <?-- -->
B. <!-- --!>
C. <!-- -->
D. </-- -- >
ANSWER : C

When processing an output XML, "new line" symbols
A. are copied into output "as is", i.e. "CR+LF" for Windows, CR for Macintosh, LF for Unix.
B. are converted to single LF symbol
C. are converted to single CR symbol
D. are discarded
ANSWER : B

Which of the following strings are a correct XML name?
A. _myElement
B. my Element
C. #myElement
D. None of the above
ANSWER : A

Which of the following strings are a correct XML name?
A. xmlExtension
B. xslNewElement
C. XMLElement#123
D. All
ANSWER : B

Which of the following XML fragments are well-formed?
A. <?xml?>
B. <?xml version="1.0"?>
C. <?xml encoding="JIS"?>
D. <?xml encoding="JIS" version="1.0"?>
ANSWER : B

What are the predefined attributes
A. xml:lang
B. xml:space
C. both
D. none.
ANSWER : C


Valid XML document means (most appropriate)
A. the document has root element
B. the document contains atleast one or more root element
C. the XML document has DTD associated with it & it complies with that DTD
D. Each element must nest inside any enclosing element property
ANSWER : C

XML uses the features of
A. HTML
B. XHTML
C. VML
D. SGML
ANSWER : D

XML document can be viewed in
A. IE 3.0
B. IE 2.0
C. IE 6.0
D. IE X.0
ANSWER : C

There is a way of describing XML data, how?
A. XML uses a DTD to describe the data
B. XML uses XSL to describe data
C. XML uses a description node to describe data
D. Both 1 and 3
ANSWER : D

What does DTD stand for?
A. Direct Type Definition
B. Document Type Definition
C. Do The Dance
D. Dynamic Type Definition
ANSWER : B

DTD includes the specifications about the markup that can be used within the document, the specifications consists of all EXCEPT
A. the browser name
B. the size of element name
C. entity declarations
D. element declarations
ANSWER : A

Which of the following XML fragments are well-formed?
A. <myElement myAttribute="someValue"/>
B. <myElement myAttribute=someValue/>
C. <myElement myAttribute=’someValue’>
D. <myElement myAttribute="someValue’/>
ANSWER : A

How can we make attributes have multiple values:
A. <myElement myAttribute="value1 value2"/>
B. <myElement myAttribute="value1" myAttribute="value2"/>
C. <myElement myAttribute="value1, value2"/>
D. attributes cannot have multiple values
ANSWER : D

Which of the following XML fragments are well-formed?
A. <myElement myAttribute="value1 <= value2"/>
B. <myElement myAttribute="value1 & value2"/>
C. <myElement myAttribute="value1 > value2"/>
D.  None of the above
ANSWER : C

The use of a DTD in XML development is:
A. required when validating XML documents
B. no longer necessary after the XML editor has been customized
C. used to direct conversion using an XSLT processor
D. a good guide to populating a templates to be filled in when generating an XML document automatically
ANSWER :  A

Parameter entities can appear in
A. xml file
B. dtd file
C. xsl file
D. Both 1 and 2
ANSWER : B


Attribute standalone="no" should be included in XML declaration if a document:
A. is linked to an external XSL stylesheet
B. has external general references
C. has processing instructions
D. has an external DTD
ANSWER : D

In XML
A. the internal DTD subset is read before the external DTD
B. the external DTD subset is read before the internal DTD
C. there is no external type of DTD
D. there is no internal type of DTD
ANSWER : A


To add the attribute named Type to the <customer> tag the syntax will be
A.  <customer attribute Type=”exelent”>
B.  <customer Type attribute =”exelent”>
C. <customer Type attribute_type=”exelent”>
D.  <customer Type=” exelent” >
ANSWER : D


The syntax for parameter entity is
A.  <! ENTITY % NAME DEFINITION>
B.  < ENTITY % NAME DEFINITION>
C.  <! ENTITY $ NAME DEFINITION>
D.  < ENTITY % NAME DEFINITION>
ANSWER : A


You can name the schema using the name attribute like
A. <schema attribute=”schema1”>
B. <schema nameattribute=”schema1”>
C. <schema nameattri=”schema1”>
D. <schema name=”schema1”>
ANSWER : D


The default model for complex type, in XML schemas for element is
A. textOnly
B. elementOnly
C. no default type
D. both 1 & 2
ANSWER : B


Microsoft XML Schema Data types for Hexadecimal digits representating octates
A. UID
B. UXID
C. UUID
D. XXID
ANSWER : C


Microsoft XML Schema Data Type “ boolean” has values
A.  True ,False
B.  True ,False or 1,0
C.  1,0
D.  any number other then zero and zero
ANSWER : C


In simple Type Built into XML schema Boolean type holds
A.  True, False
B.  1,0
C.  both (1) & (2)
D.  True/False and any number except 0
ANSWER : C


In simple type built into XML schema type float has single precision of ________ floating point
A. 16 bit
B. 32 bit
C.  8 bit
D.  4 bit
ANSWER : C


The XML DOM object is
A. Entity
B. Entity Reference
C. Comment Reference
D. Comment Data
ANSWER : B


To create a data island we use the _____________HTML element
A.  <XML>
B.  <dataisland>
C. <Island>
D. <XMLIsland>
ANSWER : A


To bind the HTML element <INPUT> Type in text with the datasource “ dsoCustomer” we use
A.  <INPUT TYPE=”TEXT” DATAFIELD=”#dsoCustomer”>
B. <INPUT TYPE=”TEXT” DATASRC=” dsoCustomer”>
C. <INPUT TYPE=”TEXT” DATASRC=” #dsoCustomer” >
D. <INPUT TYPE=”TEXT” DATAFLD=” #dsoCustomer”>
ANSWER : C


XML DSOs has the property for the number of pages of data the recordset contains
A.  count
B.  number
C.  pageCount
D.  pageNumber
ANSWER : C


Whats so great about XML?
A. Easy data exchange
B. High speed on network
C. Only (2)is correct
D. Both (1) & (2)
ANSWER : D


For XML document to be valid
A.  document need to be well formed also
B.  document need not to be well formed
C.  document need to be well formed & valid
D.  document validity has no relationship with well formedness
ANSWER :  C

 <?xml version=” 1.0” standalone=” yes” encoding=”UTF-8” ?>
A.  it shows that the version is 1.0
B.  shows thatit is standalone
C.  the standalone is wrong
D.  version attribute is not in XML
ANSWER : C


The attribute used to define a new namespace is
A.  XMLNS
B.  XmlNameSpace
C.  Xmlns
D.  XmlNs
ANSWER : C


To match the root node in XMLT transform the syntax will be
A. <xsl:template match=”Document”>
B. <xsl:template match=”Root”>
C. <xsl:template match=”RootNode”>
D. <xsl:template match=” /”>
ANSWER : D


To match the specific XML elements child like of parent element is the syntax will be
A. <xsl:template match=”PLANET_NAME”>
B.<xsl:template match=”PLANET/NAME”>
C. <xsl:template match=”/NAME”>
D. <xsl:template match=”//”>
ANSWER : B


PI in XML specification stands for
A.  3.14
B. priceless instruction
C. processing instruction
D. polymorphic inheritance
ANSWER : C


A validating XML application should be used when:
A. the design demands that all elements use both start and end tags
B. missing or out-of-place elements could cause application errors
C. attribute values cannot refer to external entity references
D. High performance is an important architectural constraint
ANSWER : B


A DSO operates like
A. data simulation object at server side
B. dynamic source object at client side
C. data source object at client side
D. data simulation object at client side
ANSWER : C


The XSL formating object use to format a list is
A. list-block
B. list-item
C. list-item-body
D. list-item-label
ANSWER : A


Identify the most accurate statement about the application of XML:
A. XML must be used to produce XML and HTML output.
B. XML cannot specify or contain presentation information.
C. XML is used to describe hierarchically organized information.
D. XML performs the conversion of information between different e-business applications.
ANSWER : C


The XSl formatting object which formats the data and caption of a table is
A. table
B. table-content
C. table-text
D. none of the above
ANSWER : D


The XSL formating object which holds the content of the table body
A.  table
B.  table-body
C.  table-content
D.  table-footer
ANSWER : B


The XSL formatting object which formats the data in a table
A. table
B. table-body
C. title
D. table-content
ANSWER : A


The XSL formating object use to hold the content of the label of a list item is
A. list-block
B. list item
C. list-item-body
D. list-item-label
ANSWER : D


The XSL formating object use to hold the contents of the body of a list item is
A. list-block
B. list item
C. list-item-body
D. list-item-label
ANSWER : C


XSL has formatting object “ block”
A. is not supported in XSL
B. generates a block level reference area
C. create a display block
D. groups global declarations for a style sheet
ANSWER : B


XSL has “ block container” for formating the document
A. to create a display block to format the titles
B. to create a display block to format the paragraphes
C. to create a display block to format the headlines & figures
D. to create a block level reference area
ANSWER : D


The syntax for writing the minimum occurrence for an element is
A.  <xsd:element ref=” note” min=” 0” />
B. <xsd:elements ref=” note” min=” 0” />
C. <xsd:elements ref=” note” minOccur=”0” />
D. <xsd:elements ref=” note” minOccurs=” 0” />
ANSWER : D


The syntax for writing default values for element is
A. <xsd:element name=”max” type=” xsd:integer” value=” 100” />
B. <xsd:element name=”max” type=” xsd:integer” fixValue=” 100” />
C. <xsd:element name=”max” type=” xsd:integer” default=” 100” />
D. <xsd:element name=”max” type=” xsd:integer” defaultval=” 100” />
ANSWER : C


To use XSLT in an XML system:
A. the input and output of the XSLT processor must be unparsed XML documents
B. the input and output of the XSLT processor must be a hierarchical tree representing an XML document
C. the XSLT processor must be called from a web agent
D. the XSLT processor must be given the DTD as well as the XML document instance
ANSWER : B


What is the role of the XPath language in XSL processing?
A. XPath identifies the order or path of processing to be followed as the XSL language is processed
B. XPath identifies locations in XML data to be transformed in the source tree and the locations to be generated in output tree specified in XSL translation prescriptions
C. XPath identifies the path to be followed in the execution of XSL translation prescriptions
D. XPath specifies which XSL transform files are to be used in the translation of XML
ANSWER : B


Which statement correctly describes the capabilities of the XSLT language?
A. XSLT uses the DTD to determine how XML documents will be translated
B. XSLT specifies how a hierarchical trees, representable by an XML document may be translated into non-hierarchical formats
C. XSLT specifies how a hierarchical tree, representable by an XML document, may be translated into another hierarchical tree, also representable by an XML document
D. XSLT specifies the formatting style to be used to render an XML document
ANSWER : C


XSLT processors accept as input:
A. an XML conforming document file and an XSLT specification file
B. only an XML document
C. only an XSLT specification
D. either an XML document or an XSLT specification
ANSWER : A


To match the root node in XMLT transform the syntax will be
A.  <xsl:template match=”Document”>
B. <xsl:template match=”Root”>
C. <xsl:template match=”RootNode”>
D. <xsl:template match=” /” >
ANSWER : D

To match the specific XML elements in XMLT the syntax for given name “ rootnode” is
A. <xsl:template match=” root”>
B. <xsl:template match=” /”>
C. <xsl:template match=” rootnode” >
D. <xsl:template match=” //”>
ANSWER : C


In XSLT style sheet we have syntax to match elements with id as (if id is “ change” )
A. <xsl:template match=” id(‘change’)” >
B. <xsl:template match=” (change)”>
C. <xsl:template match=” change”>
D. <xsl:template match-id=”Change”>
ANSWER : A


To match the text node (in XSLT) the syntax will be
A. <xsl:template match=” text”>
B. <xsl:template match-text=” text”>
C. <xsl:template match=text( )>
D. <xsl:template match=” text( )” >
ANSWER : D


An element declaration specifies
A. a single markup element
B. zmarkup elements
C. markup data
D. the document data
ANSWER : A


Which of the following specify that the order and content of "membership" is not important
A. <!ELEMENT membership NORULE>
B. <!ELEMENT membership EMPTY>
C. <!ELEMENT membership ALL>
D. <!ELEMENT membership ANY>
ANSWER : D


Which of the following is used to specify the attribute list of an element
A. ATTLIST
B. ?ATTLIST
C. !ATTLIST
D. #ATTLIST
ANSWER : C


Which of the following instruct the browser which stylesheet to use
A. <xml-stylesheet type="text/xsl" href="cd.xsl">
B. <xml-stylesheet type="text/xsl" xsl="cd.xsl">
C. <?xml-stylesheet type="text/xsl" href="cd.xsl"?>
D. <?xml-stylesheet type="text/xsl" xsl="cd.xsl"?>
ANSWER : C


Which of the following XSLT Patterns is used to match any descendant nodes
A. /
B. //
C. .
D. ..
ANSWER : B


Which of the following XSLT Patterns is used to match the parent node
A. /
B. //
C. .
D. ..
ANSWER : D


Which of the following is a valid XSLT iteration command
A. for
B. for-all
C. for-each
D. in-turn
ANSWER : C


What is an advantage of XML compared to HTML?
A. XML works on more platforms.
B. XML is suited to using Web pages as front ends to databases.
C. XML was designed for portable phones.
D. XML is simpler to learn than HTML.
ANSWER : B


The following best describes the development of XML.
A. XML developed from HTML because WEB browsers became more powerful.
B. XML is designed as a replacement because SGML can not be used for document development.
C. XML builds on HTMLs ability to provide content to virtually any audience by adding the power of intelligent content.
D. XML is the modern replacement for HTML and SGML, taking the good points from each, making both of those languages obsolete.
ANSWER : C


The correct priority for implementing XML based IETMs is :
A. Develop DTD, conduct a pilot project, create a modular library, train staff.
B. Train staff, convert legacy documents, develop DTD, create modular library.
C. Conduct pilot program, train staff, create modular library, develop DTD
D. Conduct pilot program, train staff, develop DTD, convert documents, purchace XML tools.
ANSWER : C


Which of the following statements is true:
A. XML is a direct subset of SGML
B. SGML is an application of HTML
C. XML is a kind of dynamic HTML
D. XHTML is XML rewritten in HTML
ANSWER : A


What is a qualified name?
A. Any name conforming to the XML Names specification
B. A name having prefix and local name separated by a colon
C. A name applying only to qualified elements and attributes
D. None of the above
ANSWER : B


What is a NCName
A. A Non-Common Name
B. A Non-Conforming Name
C. A Non-Colonized Name
D. None of the above
ANSWER : C


What is the default namespace
A. The namespace used by default when no namespace is declared
B. The namespace used when two or more namespaces are referenced
C. A namespace that is referenced with the xmlns attribute, but without a prefix
D. None of the above
ANSWER : C


What is an XML namespace?
A. A set of names applied to specific spaces within an XML document, such as the head and body
B. A set of names representing a specific XML vocabulary
C. A set of names for XML documents pertaining to a particular vocabulary
D. None of the above.
ANSWER : B


From what set of names do NCNames derive?
A. Any combination of characters allowable in XML
B. Any names conforming to XML Names, minus the colon
C. Any names for elements and attributes within the DTD to which the namespace refers
D. None of the above.
ANSWER : B