You are developing a method to call a COM component. You need to use declarative security to explicitly request the runtime to perform a full stack walk.

You are developing a method to call a COM component. You need to use declarative security to
explicitly request the runtime to perform a full stack walk.  You must ensure that all callers have
the required level of trust for COM interop before the callers execute your method. Which attribute
should you place on the method?

A. [SecurityPermission(
    SecurityAction.Demand,
    Flags=SecurityPermissionFlag.UnmanagedCode)]
B. [SecurityPermission(
    SecurityAction.LinkDemand,
    Flags=SecurityPermissionFlag.UnmanagedCode)]
C. [SecurityPermission(
    SecurityAction.Assert,
    Flags = SecurityPermissionFlag.UnmanagedCode)]
D. [SecurityPermission(
    SecurityAction.Deny,
    Flags = SecurityPermissionFlag.UnmanagedCode)]

Answer: A

You develop a service application that needs to be deployed.

You develop a service application that needs to be deployed. Your network administrator creates
a specific user account for your service application. You need to configure your service
application to run in the context of this specific user account. What should you do?

A. Prior to installation, set the StartType property of the ServiceInstaller class.
B. Prior to installation, set the Account, Username, and Password properties of the 
    ServiceProcessInstaller class.
C. Use the CONFIG option of the net.exe command-line tool to install the service.
D. Use the installutil.exe command-line tool to install the service.


Answer: B

You are testing a component that serializes the Meeting class instances so that they can be saved to the file system

You are testing a component that serializes the Meeting class instances so that they can be
saved to the file system. The Meeting class has the following definition:
public class Meeting {
private string title;
public int roomNumber;
public string[] invitees;
public Meeting(){
}
public Meeting(string t){
title = t;
} }
The component contains a procedure with the following code segment.
Meeting myMeeting = new Meeting(“Goals”);
myMeeting.roomNumber = 1100;
string[] attendees = new string[2]{“Braindumps”, “Mary”};
myMeeting.invitees = attendees;
XmlSerializer xs = new XmlSerializer(typeof(Meeting));
StreamWriter writer = new StreamWriter(@"C:\Meeting.xml");
Xs.Serialize(writer, myMeeting);
writer.Close();
You need to identify the XML block that is written to the C:\Meeting.xml file as a result of running
this procedure. Which XML block represents the content that will be written to the C:\Meeting.xml
file?


A. <?xml version="1.0" encoding="utf-8"?>
    <Meeting xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <title>Goals</title>
    <roomNumber>1100</roomNumber>
    <invitee>Braindumps</invitee>
    <invitee>Mary</invitee>
    </Meeting>
B. <?xml version="1.0" encoding="utf-8"?>
    <Meeting xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <roomNumber>1100</roomNumber>
 <invitees>
    <string>Braindumps</string>
    <string>Mary</string>
    </invitees>
    </Meeting>
C. <?xml version="1.0" encoding="utf-8"?>
    <Meeting xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    title="Goals">
    <roomNumber>1100</roomNumber>
    <invitees>
    <string>Braindumps</string>
    <string>Mary</string>
    </invitees>
    </Meeting>
D. <?xml version="1.0" encoding="utf-8"?>
    <Meeting xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <roomNumber>1100</roomNumber>
    <invitees>
    <string>Braindumps</string>
    </invitees>
    <invitees>
    <string>Mary</string>
  </invitees>
    </Meeting>

Answer: B 

You are changing the security settings of a file named MyData.xml.

You are changing the security settings of a file named MyData.xml. You need to preserve the
existing inherited access rules. You also need to prevent the access rules from inheriting changes
in the future. Which code segment should you use?


A. FileSecurity^ security = gcnew
    FileSecurity(“mydata.xml”, AccessControlSections::All);security->SetAccessRuleProtection(     
    true, true);File::SetAccessControl(“mydata.xml”, security);
B. FileSecurity^ security = gcnew
    FileSecurity();security->SetAccessRuleProtection(true,     
    true);File::SetAccessControl(“mydata.xml”, security);
C. FileSecurity^ security =
    File::GetAccessControl(“mydata.xml”);security->SetAccessRuleProtection(true, true);
D. FileSecurity^ security =
    File::GetAccessControl(“mydata.xml”);security->SetAuditRuleProtection(true,     
    true);File::SetAccessControl(“mydata.xml”, security);

 
Answer: A

You are writing code for user authentication and authorization.

You are writing code for user authentication and authorization. The username, password, and
roles are stored in your application data store.
You need to establish a user security context that will be used for authorization checks such as
IsInRole. You write the following code segment to authorize the user.
if (!TestPassword(userName, password))
throw new Exception(“could not authenticate user”);String[] userRolesArray =
LookupUserRoles(userName); You need to complete this code so that it establishes the user
security context. Which code segment should you use?


A. GenericIdentity ident = new GenericIdentity(userName);GenericPrincipal currentUser =
    new GenericPrincipal(ident, userRolesArray);Thread.CurrentPrincipal = currentUser;
B. WindowsIdentity ident = new WindowsIdentity(userName);WindowsPrincipal currentUser =     
    new WindowsPrincipal(ident);Thread.CurrentPrincipal = currentUser;
C. NTAccount userNTName = new NTAccount(userName);GenericIdentity ident = new     
    GenericIdentity(userNTName.Value);GenericPrincipal currentUser = new 
    GenericPrincipal(ident, userRolesArray);Thread.CurrentPrincipal = currentUser;
D. IntPtr token = IntPtr.Zero;token = LogonUserUsingInterop(username, 
    encryptedPassword);WindowsImpersonationContext ctx = 
    WindowsIdentity.Impersonate(token);


Answer: A

You create the definition for a Vehicle class by using the following code segment.

You create the definition for a Vehicle class by using the following code segment.
public class Vehicle {
[XmlAttribute(AttributeName = "category")]
public string vehicleType;
public string model;
[XmlIgnore]
public int year;
[XmlElement(ElementName = "mileage")]
public int miles;
public ConditionType condition;
public Vehicle() {
}
public enum ConditionType {
[XmlEnum("Poor")] BelowAverage,
[XmlEnum("Good")] Average,
[XmlEnum("Excellent")] AboveAverage
}}
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 an undo buffer that stores data modifications.

You are creating an undo buffer that stores data modifications. You need to ensure that the undo
functionality undoes the most recent data modifications first. You also need to ensure that the
undo buffer permits the storage of strings only. Which code segment should you use?

A. Stack<string> undoBuffer = new Stack<string>();
B. Stack undoBuffer = new Stack();
C. Queue<string> undoBuffer = new Queue<string>();
D. Queue undoBuffer = new Queue();

Answer: A

You are creating an undo buffer that stores data modifications.

You are creating an undo buffer that stores data modifications. You need to ensure that the undo
functionality undoes the most recent data modifications first. You also need to ensure that the
undo buffer permits the storage of strings only. Which code segment should you use?

A. Dim undoBuffer As New Stack(Of String)
B. Dim undoBuffer As New Stack()
C. Dim undoBuffer As New Queue(Of String)
D. Dim undoBuffer As New Queue()

Answer:  A

You need to write a code segment that transfers the contents of a byte array named dataToSend by using a NetworkStream object named netStream

You need to write a code segment that transfers the contents of a byte array named dataToSend
by using a NetworkStream object named netStream.  You need to use a cache of size 8,192
bytes. Which code segment should you use?


A. Dim memStream As New MemoryStream(8192)memStream.Write(dataToSend, 0, _
    CType(netStream.Length, Integer))
B. Dim memStream As New MemoryStream(8192)netStream.Write(dataToSend, 0, _
    CType(memStream.Length, Integer))
C. Dim bufStream As New BufferedStream(netStream, 8192)
    bufStream.Write(dataToSend, 0, dataToSend.Length)
D. Dim bufStream As New BufferedStream(netStream)
    bufStream.Write(dataToSend, 0, 8192)


Answer: C

You are writing a method that returns an ArrayList named al. You need to ensure that changes to the ArrayList are performed in a thread-safe manner. Which code segment should you use?

You are writing a method that returns an ArrayList named al. You need to ensure that changes to
the ArrayList are performed in a thread-safe manner. Which code segment should you use?


A. ArrayList^ al = gcnew ArrayList();lock (al->SyncRoot){
    return al;}
B. ArrayList^ al = gcnew ArrayList();lock (al->SyncRoot.GetType()){
    return al;}
C. ArrayList^ al = gcnew ArrayList();Monitor::Enter(al);Monitor::Exit(al);return al;
D. ArrayList^ al = gcnew ArrayList();ArrayList^ sync_al = ArrayList::Synchronized(al);return   
    sync_al;


Answer: D 

You need to select a class that is optimized for key-based item retrieval from both small and large collections. Which class should you choose?

You need to select a class that is optimized for key-based item retrieval from both small and large collections. Which class should you choose?

A. OrderedDictionary class
B. HybridDictionary class
C. ListDictionary class
D. Hashtable class


Answer: B 




You are developing a server application that will transmit sensitive information on a network.

You are developing a server application that will transmit sensitive information on a network. You
create an X509Certificate object named certificate and a TcpClient object named client.
You need to create an SslStream to communicate by using the Transport Layer Security 1.0
protocol. Which code segment should you use?


A. SslStream^ ssl = gcnew
    SslStream(Client->GetStream());ssl->AuthenticateAsServer(certificate, false,     
    SslProtocols::None, true);
B. SslStream ^ssl = gcnew
    SslStream(Client->GetStream());ssl->AuthenticateAsServer(certificate, false, 
    SslProtocols::SSl3, true);
C. SslStream ^ssl = gcnew
    SslStream(Client->GetStream());ssl->AuthenticateAsServer(certificate, false, 
    SslProtocols::SSl2, true);
D. SslStream ^ssl = gcnew
    SslStream(Client->GetStream());ssl->AuthenticateAsServer(certificate, false, SslProtocols::Tls, 
    true);


Answer: D

You need to write a multicast delegate that accepts a DateTime argument and returns a Boolean value. Which code segment should you use?

You need to write a multicast delegate that accepts a DateTime argument and returns a Boolean
value. Which code segment should you use?

A. public delegate int PowerDeviceOn(bool,
    DateTime);
B. public delegate bool PowerDeviceOn(Object,
    EventArgs);
C. public delegate void PowerDeviceOn(DateTime);
D. public delegate bool PowerDeviceOn(DateTime);
 
 

Answer: A 







You are developing an application to assist the user in conducting electronic surveys.

You are developing an application to assist the user in conducting electronic surveys. The survey
consists of 25 true-or-false questions. You need to perform the following tasks:
Initialize each answer to true.Minimize the amount of memory used by each survey.
Which storage option should you choose?


A. BitVector32^ answers = gcnew BitVector32(1);
B. BitVector32^ answers = gcnew BitVector32(-1);
C. BitArray^ answers = gcnew BitArray(1);
D. BitArray^ answers = gcnew BitArray(-1);

 
Answer: B 

You write a class named Employee that includes the following code segment. public class Employee {

You write a class named Employee that includes the following code segment. public class
Employee {
string employeeId, employeeName, jobTitleName;
public string GetName() { return employeeName; }
public string GetTitle() { return jobTitleName; } You need to expose this class to COM in a type
library. The COM interface must also facilitate forward-compatibility across new versions of the
Employee class. You need to choose a method for generating the COM interface.
What should you do?


A. Add the following attribute to the class
    definition.[ClassInterface(ClassInterfaceType.None)]public class Employee {
B. Add the following attribute to the class
    definition.[ClassInterface(ClassInterfaceType.AutoDual)]public class Employee {
C. Add the following attribute to the class definition.[ComVisible(true)]public class
    Employee {
D. Define an interface for the class and add the following attribute to the class
    definition.[ClassInterface(ClassInterfaceType.None)]public class Employee : IEmployee
    {


Answer: D
 

You need to create a dynamic assembly named MyAssembly. You also need to save the assembly to disk. Which code segment should you use?

You need to create a dynamic assembly named MyAssembly. You also need to save the
assembly to disk. Which code segment should you use?

A. AssemblyName^ myAssemblyName = gcnew
    AssemblyName();myAssemblyName->Name = “MyAssembly”; AssemblyBuilder^
    myAssemblyBuilder =
    AppDomain::CurrentDomain->DefineDynamicAssembly(
    myAssemblyName,
    AssemblyBuilderAccess::Run);myAssemblyBuilder->Save(“MyAssembly.dll”);
B. AssemblyName^ myAssemblyName = gcnew
    AssemblyName();myAssemblyName->Name = “MyAssembly”; AssemblyBuilder^
    myAssemblyBuilder =
    AppDomain::CurrentDomain->DefineDynamicAssembly(
    myAssemblyName,
    AssemblyBuilderAccess::Save);myAssemblyBuilder->Save(“MyAssembly.dll”);
C. AssemblyName^ myAssemblyName = gcnew AssemblyName();AssemblyBuilder^
    myAssemblyBuilder =
    AppDomain::CurrentDomain->DefineDynamicAssembly(
    myAssemblyName,
    AssemblyBuilderAccess::RunAndSave);myAssemblyBuilder->Save(“MyAssembly.dll”);
D. AssemblyName^ myAssemblyName =
    gcnew AssemblyName(“MyAssembly”); AssemblyBuilder^ myAssemblyBuilder =
    AppDomain::CurrentDomain->DefineDynamicAssembly(
    myAssemblyName,
    AssemblyBuilderAccess::Save);myAssemblyBuilder->Save(“c:\\MyAssembly.dll”);


Answer: B 

You are using the Microsoft Visual Studio 2005 IDE to examine the output of a method that returns a string.

You are using the Microsoft Visual Studio 2005 IDE to examine the output of a method that
returns a string. You assign the output of the method to a string variable named fName. You need
to write a code segment that prints the following on a single line The message: "Test Failed: " The
value of fName if the value of fName does not equal "Braindumps" You also need to ensure that
the code segment simultaneously facilitates uninterrupted execution of the application. Which
code segment should you use?

A. Debug::Assert(fName == “Braindumps”, “Test Failed: ”, fName);
B. Debug::WriteLineIf(fName != “Braindumps”, fName, “Test Failed”);
C. if (fName != "Braindumps") {
    Debug::Print(“Test Failed: ”);
    Debug::Print(fName);}
D. if (fName != "Braindumps") {
    Debug::WriteLine(“Test Failed: ”);
    Debug::WriteLine(fName);}


Answer: B

You are writing a method that accepts a string parameter named message.

You are writing a method that accepts a string parameter named message.
Your method must break the message parameter into individual lines of text and pass each line to
a second method named Process.
Which code segment should you use?

A. StringReader^ reader = gcnew
    StringReader(message);Process(reader->ReadToEnd());reader->Close();
B. StringReader^ reader = gcnew StringReader(message);while(reader->Peak() != -1) {
    String^ line = reader->Read().ToString();
    Process(line);}reader->Close();
C. StringReader^ reader = gcnew
    StringReader(message);Process(reader->ToString());reader->Close();
D. StringReader^ reader = gcnew StringReader(message);while(reader->Peak() != -1) {
    Process(reader->ReadLine());}reader->Close();


Answer: D 

You are testing a method that examines a running process.

You are testing a method that examines a running process. This method returns an ArrayList
containing the name and full path of all modules that are loaded by the process.
You need to list the modules loaded by a process named C:\TestApps\Process1.exe.
Which code segment should you use?


A. Dim ar As New ArrayList()Dim procs As Process()Dim modules As 
    ProcessModuleCollectionprocs = Process.GetProcesses("Process1")If procs.Length > 0
    Thenmodules = procs(0).Modules
    For Each pm As ProcessModule In Modules
    ar.Add(pm.ModuleName)
    NextEnd If
B. Dim ar As New ArrayList()Dim procs As Process()Dim modules As
    ProcessModuleCollectionprocs = Process.GetProcesses("C:\TestApps\Process1.exe")If
    procs.Length > 0 Thenmodules = procs(0).Modules
    For Each pm As ProcessModule In Modules
    ar.Add(pm.ModuleName)
    Next End If
C. Dim ar As New ArrayList()Dim procs As Process()Dim modules As
    ProcessModuleCollectionprocs = Process.GetProcessesByName("Process1")If
    procs.Length > 0 Thenmodules = procs(0).Modules
    For Each pm As ProcessModule In Modules
    ar.Add(pm.FileName)
    Next End If
D. Dim ar As New ArrayList()Dim procs As Process()Dim modules As
    ProcessModuleCollectionprocs =
    _Process.GetProcessesByName("C:\TestApps\Process1.exe")If procs.Length > 0
    Thenmodules = procs(0).Modules
    For Each pm As ProcessModule In Modules
    ar.Add(pm.FileName)
    Next End If


Answer: C

You are developing an application that will use custom authentication and role-based security.

You are developing an application that will use custom authentication and role-based security.
You need to write a code segment to make the runtime assign an unauthenticated principal object
to each running thread.
Which code segment should you use?

A. AppDomain domain =
    AppDomain.CurrentDomain;domain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal);
B. AppDomain domain = AppDomain.CurrentDomain;domain.SetThreadPrincipal(new     
    WindowsPrincipal(null));
C. AppDomain domain = AppDomain.CurrentDomain;
    domain.SetAppDomainPolicy(
    PolicyLevel.CreateAppDomainLevel());
D. AppDomain domain = AppDomain.CurrentDomain;domain.SetPrincipalPolicy(     
    PrincipalPolicy.UnauthenticatedPrincipal);


Answer: D

You are creating a new security policy for an application domain.

You are creating a new security policy for an application domain. You write the following lines of
code. PolicyLevel ^policy = PolicyLevel::CreateAppDomainLevel();
PolicyStatement ^noTrustStatement =
gcnew PolicyStatement(
policy->GetNamedPermissionSet(“Nothing”)); PolicyStatement ^fullTrustStatement =
gcnew PolicyStatement(
policy->GetNamedPermissionSet(“FullTrust”)); You need to arrange code groups for the policy so
that loaded assemblies default to the Nothing permission set. If the assembly originates from a
trusted zone, the security policy must grant the assembly the FullTrust permission set. Which
code segment should you use?


A. CodeGroup ^group1 = gcnew FirstMatchCodeGroup(
    gcnew ZoneMembershipCondition(SecurityZone::Trusted),
    fullTrustStatement); CodeGroup ^group2 = gcnew UnionCodeGroup(
    gcnew AllMembershipCondition(),
    noTrustStatement); group1->AddChild(group2);
B. CodeGroup ^group1 = gcnew FirstMatchCodeGroup(
    gcnew AllMembershipCondition(),
    noTrustStatement); CodeGroup ^group2 = gcnew UnionCodeGroup(
    gcnew ZoneMembershipCondition(SecurityZone::Trusted),
    fullTrustStatement); group1->AddChild(group2);
C. CodeGroup ^group = gcnew UnionCodeGroup(
    gcnew ZoneMembershipCondition(SecurityZone::Trusted),
    fullTrustStatement);
D. CodeGroup ^group = gcnew FirstMatchCodeGroup(
    gcnew AllMembershipCondition(),
    noTrustStatement);



Answer: B

You are using the Microsoft Visual Studio 2005 IDE to examine the output of a method that returns a string.

You are using the Microsoft Visual Studio 2005 IDE to examine the output of a method that
returns a string.  You assign the output of the method to a string variable named fName. You need
to write a code segment that prints the following on a single line The message: "Test Failed: " The
value of fName if the value of fName does not equal "Braindumps" You also need to ensure that
the code segment simultaneously facilitates uninterrupted execution of the application. Which
code segment should you use?

A. Debug::Assert(fName == “Braindumps”, “Test Failed: ”, fName);

B. Debug::WriteLineIf(fName != “Braindumps”, fName, “Test Failed”);

C. if (fName != "Braindumps") {
    Debug::Print(“Test Failed: ”);
    Debug::Print(fName);}

D. if (fName != "Braindumps") {
    Debug::WriteLine(“Test Failed: ”);
    Debug::WriteLine(fName);}


Answer: B

You are writing a method that accepts a string parameter named message.

You are writing a method that accepts a string parameter named message.
Your method must break the message parameter into individual lines of text and pass each line to a second method named Process.
Which code segment should you use?

A. StringReader^ reader = gcnew
    StringReader(message);Process(reader->ReadToEnd());reader->Close();
B. StringReader^ reader = gcnew StringReader(message);while(reader->Peak() != -1) {
    String^ line = reader->Read().ToString();
    Process(line);}reader->Close();
C. StringReader^ reader = gcnew
    StringReader(message);Process(reader->ToString());reader->Close();
D. StringReader^ reader = gcnew StringReader(message);while(reader->Peak() != -1) {
    Process(reader->ReadLine());}reader->Close();


Answer: D

You are testing a method that examines a running process.

You are testing a method that examines a running process. This method returns an ArrayList
containing the name and full path of all modules that are loaded by the process.
You need to list the modules loaded by a process named C:\TestApps\Process1.exe.
Which code segment should you use?

A. Dim ar As New ArrayList()Dim procs As Process()Dim modules As 
    ProcessModuleCollectionprocs = Process.GetProcesses("Process1")If procs.Length > 0
    Thenmodules = procs(0).Modules
    For Each pm As ProcessModule In Modules
    ar.Add(pm.ModuleName)
    NextEnd If

B. Dim ar As New ArrayList()Dim procs As Process()Dim modules As
    ProcessModuleCollectionprocs = Process.GetProcesses("C:\TestApps\Process1.exe")If
    procs.Length > 0 Thenmodules = procs(0).Modules
    For Each pm As ProcessModule In Modules
    ar.Add(pm.ModuleName)
    Next End If

C. Dim ar As New ArrayList()Dim procs As Process()Dim modules As
    ProcessModuleCollectionprocs = Process.GetProcessesByName("Process1")If
    procs.Length > 0 Thenmodules = procs(0).Modules
    For Each pm As ProcessModule In Modules
    ar.Add(pm.FileName)
    Next End If

D. Dim ar As New ArrayList()Dim procs As Process()Dim modules As
    ProcessModuleCollectionprocs =
    _Process.GetProcessesByName("C:\TestApps\Process1.exe")If procs.Length > 0
    Thenmodules = procs(0).Modules
    For Each pm As ProcessModule In Modules
    ar.Add(pm.FileName)
    Next End If

 
Answer: C

You are developing an application that will use custom authentication and role-based security.

You are developing an application that will use custom authentication and role-based security.

You need to write a code segment to make the runtime assign an unauthenticated principal object
to each running thread.
Which code segment should you use?

A. AppDomain domain =
    AppDomain.CurrentDomain;domain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal);

B. AppDomain domain = AppDomain.CurrentDomain;domain.SetThreadPrincipal(new     
    WindowsPrincipal(null));

C. AppDomain domain = AppDomain.CurrentDomain;
    domain.SetAppDomainPolicy(
    PolicyLevel.CreateAppDomainLevel());

D. AppDomain domain = AppDomain.CurrentDomain;domain.SetPrincipalPolicy(     
    PrincipalPolicy.UnauthenticatedPrincipal);


Answer: D

You are creating a new security policy for an application domain.

You are creating a new security policy for an application domain. You write the following lines of
code. PolicyLevel ^policy = PolicyLevel::CreateAppDomainLevel();
PolicyStatement ^noTrustStatement =
gcnew PolicyStatement(
policy->GetNamedPermissionSet(“Nothing”)); PolicyStatement ^fullTrustStatement =
gcnew PolicyStatement(
policy->GetNamedPermissionSet(“FullTrust”)); You need to arrange code groups for the policy so
that loaded assemblies default to the Nothing permission set. If the assembly originates from a
trusted zone, the security policy must grant the assembly the FullTrust permission set. Which
code segment should you use?

A. CodeGroup ^group1 = gcnew FirstMatchCodeGroup(
    gcnew ZoneMembershipCondition(SecurityZone::Trusted),
    fullTrustStatement); CodeGroup ^group2 = gcnew UnionCodeGroup(
    gcnew AllMembershipCondition(),
    noTrustStatement); group1->AddChild(group2);

B. CodeGroup ^group1 = gcnew FirstMatchCodeGroup(
    gcnew AllMembershipCondition(),
    noTrustStatement); CodeGroup ^group2 = gcnew UnionCodeGroup(
    gcnew ZoneMembershipCondition(SecurityZone::Trusted),
    fullTrustStatement); group1->AddChild(group2);

C. CodeGroup ^group = gcnew UnionCodeGroup(
    gcnew ZoneMembershipCondition(SecurityZone::Trusted),
    fullTrustStatement);

D. CodeGroup ^group = gcnew FirstMatchCodeGroup(
    gcnew AllMembershipCondition(),
    noTrustStatement);

 
Answer: B

You are using the Microsoft Visual Studio 2005 IDE to examine the output of a method that returns a string.

You are using the Microsoft Visual Studio 2005 IDE to examine the output of a method that
returns a string. You assign the output of the method to a string variable named fName. You need
to write a code segment that prints the following on a single line The message: "Test Failed: " The
value of fName if the value of fName does not equal "Braindumps" You also need to ensure that
the code segment simultaneously facilitates uninterrupted execution of the application. Which
code segment should you use?

A. Debug.Assert(fName == “Braindumps”, “Test Failed: ”, fName);
B. Debug.WriteLineIf(fName != “Braindumps”, fName, “Test Failed”);
C. if (fName != "Braindumps") {
    Debug.Print(“Test Failed: ”);
    Debug.Print(fName);
    }
D. if (fName != "Braindumps") {
    Debug.WriteLine(“Test Failed: ”);
    Debug.WriteLine(fName);
    }


Answer: B

You are developing a server application that will transmit sensitive information on a network.

You are developing a server application that will transmit sensitive information on a network. You
create an X509Certificate object named certificate and a TcpClient object named client.
You need to create an SslStream to communicate by using the Transport Layer Security 1.0
protocol. Which code segment should you use?


A. Dim objSSL As New
    SslStream(client.GetStream)objSSL.AuthenticateAsServer(certificate, False, _
    SslProtocols.None, True)

B. Dim objSSL As New
    SslStream(client.GetStream)objSSL.AuthenticateAsServer(certificate, False, _
    SslProtocols.Ssl3, True)

C. Dim objSSL As New
    SslStream(client.GetStream)objSSL.AuthenticateAsServer(certificate, False, _
    SslProtocols.Ssl2, True)

D. Dim objSSL As New
    SslStream(client.GetStream)objSSL.AuthenticateAsServer(certificate, False, _
    SslProtocols.Tls, True)


Answer: D

You are creating a class named Age.

You are creating a class named Age.
You need to ensure that the Age class is written such that collections of Age objects can be
sorted. Which code segment should you use?

A. public ref class Age {
    public : Int32 Value;
    public : virtual Object CompareTo(Object^ obj) {
    if (obj->GetType() == Age::GetType()) {
    Age^ _age = (Age^) obj;
    return Value.CompareTo(obj);
    }
    throw gcnew ArgumentException(“object not an Age”);
    }};
B. public ref class Age {
    public : Int32 Value;
    public : virtual Object CompareTo(Int32^ iValue) {
    try {
    return Value.CompareTo(iValue);
    } catch (Exception^ ex) {
    throw gcnew ArgumentException(“object not an Age”);
    }
    }};
C. public ref class Age : public IComparable {
    public : Int32 Value;
    public : virtual Int32 CompareTo(Object^ obj) {
    if (obj->GetType() == Age::GetType()) {
    Age^ _age = (Age^) obj;
    return Value.CompareTo(_age->Value);
    }
    throw gcnew ArgumentException(“object not an Age”);
    }};
D. public ref class Age : public IComparable {
    public : Int32 Value;
    public : virtual Int32 CompareTo(Object^ obj) {
    try {
    return Value.CompareTo(((Age^) obj)->Value);
    } catch (Exception^ ex) {
    return -1;
    }
    }};


 Answer: C 

You create a method that runs by using the credentials of the end user.

You create a method that runs by using the credentials of the end user.  You need to use
Microsoft Windows groups to authorize the user. You must add a code segment that identifies
whether a user is in the local group named Clerk.
Which code segment should you use?


A. Dim objUser As WindowsIdentity = WindowsIdentity.GetCurrentFor Each objGroup
    As IdentityReference In objUser.Groups
    Dim objNT As NTAccount = _
    DirectCast(objGroup.Translate( _
    Type.GetType("NTAccount")), NTAccount)
    Dim blnAuth As Boolean = objNT.Value.Equals( _
    Environment.MachineName & "\Clerk")
    If blnAuth Then Exit ForNext

B. Dim objUser As WindowsPrincipal = _
    DirectCast(Thread.CurrentPrincipal, WindowsPrincipal)Dim blnAuth As Boolean =
    objUser.IsInRole("Clerk")

C. Dim objUser As GenericPrincipal = _
    DirectCast(Thread.CurrentPrincipal, GenericPrincipal)Dim blnAuth As Boolean =
    objUser.IsInRole("Clerk")

D. Dim objUser As WindowsPrincipal = _
    DirectCast(Thread.CurrentPrincipal, WindowsPrincipal)Dim blnAuth As Boolean = _
    objUser.IsInRole(Environment.MachineName)


Answer: B

You are writing a method that returns an ArrayList named al. You need to ensure that changes to the ArrayList are performed in a thread-safe manner. Which code segment should you use?

You are writing a method that returns an ArrayList named al. You need to ensure that changes to
the ArrayList are performed in a thread-safe manner. Which code segment should you use?

A. Dim al As ArrayList = New ArrayList()SyncLock al.SyncRoot
    Return alEnd SyncLock

B. Dim al As ArrayList = New ArrayList()SyncLock al.SyncRoot.GetType()
    Return alEnd SyncLock

C. Dim al As ArrayList = New ArrayList()Monitor.Enter(al)Monitor.Exit(al)Return al

D. Dim al As ArrayList = New ArrayList()Dim sync_al as ArrayList =
    ArrayList.Synchronized(al)Return sync_al


Answer: D 




You are creating an application that lists processes on remote computers.

You are creating an application that lists processes on remote computers. The application
requires a method that performs the following tasks: Accept the remote computer name as a
string parameter named strComputer.Return an ArrayList object that contains the names of all
processes that are running on that computer. You need to write a code segment that retrieves the
name of each process that is running on the remote computer and adds the name to the ArrayList
object. Which code segment should you use?

A. Dim al As New ArrayList()Dim procs As Process() = _
    Process.GetProcessesByName(strComputer)Dim proc As ProcessFor Each proc In procs
    al.Add(proc)Next
B. Dim al As New ArrayList()Dim procs As Process() =
    Process.GetProcesses(strComputer)Dim proc As ProcessFor Each proc In procs
    al.Add(proc)Next
C. Dim al As New ArrayList()Dim procs As Process() = _
    Process.GetProcessesByName(strComputer)Dim proc As ProcessFor Each proc In procs
    al.Add(proc.ProcessName)Next
D. Dim al As New ArrayList()Dim procs As Process() =
    Process.GetProcesses(strComputer)Dim proc As ProcessFor Each proc In procs
    al.Add(proc.ProcessName)Next


Answer: D

You are testing a newly developed method named PersistToDB. This method accepts a parameter of type EventLogEntry.

You are testing a newly developed method named PersistToDB. This method accepts a
parameter of type EventLogEntry.  This method does not return a value. You need to create a
code segment that helps you to test the method. The code segment must read entries from the
application log of local computers and then pass the entries on to the PersistToDB method. The
code block must pass only events of type Error or Warning from the source MySource to the
PersistToDB method. Which code segment should you use?

A. EventLog^ myLog = gcnew EventLog(“Application”, “.”);for each (EventLogEntry^
    entry in myLog->Entries) {
    if (entry->Source == "MySource") {
    PersistToDB(entry);
    }}
B. EventLog^ myLog = gcnew EventLog(“Application”, “.”);myLog->Source = “MySource”;for each     
    (EventLogEntry^ entry in myLog->Entries) {
    if (entry->EntryType == (EventLogEntryType::Error &
    EventLogEntryType::Warning)) {
    PersistToDB(entry);}}
C. EventLog^ myLog = gcnew EventLog(“Application”, “.”);for each (EventLogEntry^
    entry in myLog->Entries) {
    if (entry->Source == "MySource") {
    if (entry->EntryType == EventLogEntryType::Error ||
    entry->EntryType == EventLogEntryType::Warning) {
    PersistToDB(entry);
    }
    }
D. EventLog^ myLog = gcnew EventLog(“Application”, “.”);myLog->Source = “MySource”;for       each     
    (EventLogEntry^ entry in myLog->Entries) {
    if (entry->EntryType == EventLogEntryType::Error ||
    entry->EntryType == EventLogEntryType::Warning) {
    PersistToDB(entry);
    }}
    

Answer: C

You are developing a method that searches a string for a substring. The method will be localized to Italy.

You are developing a method that searches a string for a substring. The method will be localized
to Italy.
Your method accepts the following parameters: The string to be searched, which is named
SearchListThe string for which to search, which is named SearchValue You need to write the
code. Which code segment should you use?

A. Return SearchList.IndexOf(SearchValue)
B. Dim objComparer As CompareInfo = _
    New CultureInfo("it-IT").CompareInfoReturn objComparer.Compare(SearchList,
    SearchValue)
C. Dim objComparer As CompareInfo = _
    New CultureInfo("it-IT").CompareInfoIf SearchList.IndexOf(SearchValue) > 0 Then
    Return TrueElse
    Return FalseEnd If
D. Dim objComparer As CompareInfo = _
    New CultureInfo("it-IT").CompareInfoIf objComparer.IndexOf(SearchList,
    SearchValue) > 0 Then
    Return TrueElse
    Return FalseEnd If


Answer: D

You are testing a method that examines a running process.

You are testing a method that examines a running process. This method returns an ArrayList
containing the name and full path of all modules that are loaded by the process.
You need to list the modules loaded by a process named C:\TestApps\Process1.exe.
Which code segment should you use?

A. ArrayList^ ar = gcnew ArrayList();array<Process^> procs;ProcessModuleCollection^     
    modules;procs = Process::GetProcesses(@”Process1”);if(procs->Length > 0) {
    modules = procs[0]->Modules;
    for each (ProcessModule^ mod in modules) {
    ar->Add(mod->ModuleName);
    }}
B. ArrayList^ ar = gcnew ArrayList();array<Process^> procs;ProcessModuleCollection^     
    modules;procs = Process::GetProcesses(@”C:\TestApps\Process1.exe”);if
    (procs->Length > 0) {
    modules = procs[0]->Modules;
    for each (ProcessModule^ mod in modules) {
    ar->Add(mod->ModuleName);
    }}
C. ArrayList^ ar = gcnew ArrayList();array<Process^> procs;ProcessModuleCollection^     
    modules;procs = Process::GetProcesses(@”Process1”);if (procs->Length > 0) {
    modules = procs[0]->Modules;
    for each (ProcessModule^ mod in modules) {
    ar->Add(mod->FileName);
    }}
D. ArrayList^ ar = gcnew ArrayList();array<Process^> procs;ProcessModuleCollection^ 
    modules;procs = Process->GetProcessesByName(@”C:\TestApps\Process1.exe”);if (procs-    
    >Length > 0) {
    modules = procs[0]->Modules;
    for each (ProcessModule^ mod in modules) {
    ar->Add(mod->FileName);
    }}


Answer: C
 

You are developing an application to perform mathematical calculations.

You are developing an application to perform mathematical calculations.  You develop a class
named CalculationValues. You write a procedure named PerformCalculation that operates on an
instance of the class. You need to ensure that the user interface of the application continues to
respond while calculations are being performed. You need to write a code segment that calls the
PerformCalculation procedure to achieve this goal.
Which code segment should you use?

A. Private Sub PerformCalculation()...End Sub Private Sub DoWork()
    Dim myValues As New CalculationValues()
    Dim newThread As New Thread( _
    New ThreadStart(AddressOf PerformCalculation))
    newThread.Start(myValues)End Sub
B. Private Sub PerformCalculation()...End Sub Private Sub DoWork()
    Dim myValues As New CalculationValues()
    Dim delStart As New ThreadStart( _AddressOf PerformCalculation)
    Dim newThread As New Thread(delStart)If newThread.IsAlive
    ThennewThread.Start(myValues)End IfEnd Sub
C. Private Sub PerformCalculation ( _ByVal values As CalculationValues)...End Sub
    Private Sub DoWork()
    Dim myValues As New CalculationValues()
    Application.DoEvents()
    PerformCalculation(myValues)
    Application.DoEvents()End Sub
D. Private Sub PerformCalculation ( _ByVal values As Object)...End Sub Private Sub
    DoWork()
    Dim myValues As New CalculationValues()
    Dim newThread As New Thread( _
    New ParameterizedThreadStart( _AddressOf PerformCalculation))
    newThread.Start(myValues)End Sub


Answer: D 

You need to call an unmanaged function from your managed code by using platform invoke services. What should you do?

You need to call an unmanaged function from your managed code by using platform invoke
services. What should you do?


A. Create a class to hold DLL functions and then create prototype methods by using managed 
    code.
B. Register your assembly by using COM and then reference your managed code from COM.
C. Export a type library for your managed code.
D. Import a type library as an assembly and then create instances of COM object.


Answer: A
 

You are creating an application that retrieves values from a custom section of the application configuration file. The custom section uses XML as shown in the following block.

You are creating an application that retrieves values from a custom section of the application
configuration file. The custom section uses XML as shown in the following block.

<ProjectSection name="ProjectBraindumps">
<role name="administrator" />
<role name="manager" />
<role name="support" />
</ProjectSection>

You need to write a code segment to define a class named Role. You need to ensure that the
Role class is initialized with values that are retrieved from the custom section of the configuration
file. Which code segment should you use?

A. public class Role : ConfigurationElement {
    internal string_ElementName = “name”;
    [ConfigurationProperty("role")]
    public string Name {
    get {
    return ((string)base[“role”]);
    }
    }
    }
B. public class Role : ConfigurationElement {
    internal string_ElementName = “role”;
    [ConfigurationProperty("name", RequiredValue = true)]
    public string Name {
    get {
    return ((string)base[“name”]);
    }
    }
    }
C. public class Role : ConfigurationElement {
    internal string_ElementName = “role”;
    private String_name;
    [ConfigurationProperty("name")]
    public string Name {
    get {
    return_name;
    }
    }
    }
D. public class Role : ConfigurationElement {
    internal string_ElementName = “name”;
    private String_name;
    [ConfigurationProperty("role", RequiredValue = true)]
    public string Name {
    get {
    return_name;
    }
    }
    }



Answer: B
 

You develop a service application named FileService.

You develop a service application named FileService. You deploy the service application to
multiple servers on your network. You implement the following code segment. (Line numbers are
included for reference only.)
01 Public Sub StartService(ByVal serverName As String)
02 Dim crtl As ServiceController = _
03 New ServiceController("FileService")
04 If crtl.Status = ServiceControllerStatus.Stopped Then
05 End If
06 End Sub
You need to develop a routine that will start FileService if it stops. The routine must start
FileService on the server identified by the serverName input parameter.
Which two lines of code should you add to the code segment? (Each correct answer presents
part of the solution. Choose two.)


A. Insert the following line of code between lines 03 and 04:crtl.ServiceName = serverName

B. Insert the following line of code between lines 03 and 04:crtl.MachineName = serverName

C. Insert the following line of code between lines 03 and 04:crtl.Site.Name = serverName

D. Insert the following line of code between lines 04 and 05:crtl.Continue()

E. Insert the following line of code between lines 04 and 05:crtl.Start()

F. Insert the following line of code between lines 04 and 05:crtl.ExecuteCommand(0)



Answer: B,E

You are creating an application that lists processes on remote computers.

You are creating an application that lists processes on remote computers.  The application
requires a method that performs the following tasks: Accept the remote computer name as a
string parameter named strComputer.Return an ArrayList object that contains the names of all
processes that are running on that computer. You need to write a code segment that retrieves the
name of each process that is running on the remote computer and adds the name to the ArrayList
object. Which code segment should you use?


A. ArrayList^ al = gcnew ArrayList();array<Process^> procs =         
    Process::GetProcessesByName(StrComputer);for each (Process^ proc in procs) {
    al->Add(proc);}

B. ArrayList^ al = gcnew ArrayList();array<Process^> procs =     
    Process::GetProcesses(StrComputer);for each (Process^ proc in procs) {
    al->Add(proc);}

C. ArrayList^ al = gcnew ArrayList();array<Process^> procs = 
    Process::GetProcessesByName(StrComputer);for each (Process^ proc in procs) {
    al->Add(proc->ProcessName);}

D. ArrayList^ al = gcnew ArrayList();array<Process^> procs = 
    Process::GetProcesses(StrComputer);for each (Process^ proc in procs) {
    al->Add(proc->ProcessName);}


Answer: D 

You are developing a fiscal report for a customer.

You are developing a fiscal report for a customer.  Your customer has a main office in the United
States and a satellite office in Mexico.
You need to ensure that when users in the satellite office generate the report, the current date is
displayed in Mexican Spanish format. Which code segment should you use?


A. DateTimeFormatInfo dtfi = new CultureInfo(“es-MX”, false).DateTimeFormat;
    DateTime dt = new DateTime(DateTime.Today.Year, DateTime.Today.Month,
    DateTime.Today.Day); string dateString = dt.ToString(dtfi.LongDatePattern);

B. Calendar cal = new CultureInfo(“es-MX”, false).Calendar; DateTime dt = new     
    DateTime(DateTime.Today.Year, DateTime.Today.Month, DateTime.Today.Day);
    Strong DateString = dt.ToString();

C. string dateString = DateTimeFormatInfo.CurrentInfo
    GetMonthName(DateTime.Today.Month);

D. string dateString = DateTime.Today.Month.ToString(“es-MX”);


Answer: A

You need to generate a report that lists language codes and region codes. Which code segment should you use?

You need to generate a report that lists language codes and region codes.
Which code segment should you use?

A. foreach (CultureInfo culture in
    CultureInfo.GetCultures(CultureTypes.SpecificCultures)) {
    // Output the culture information...}
B. CultureInfo culture = new CultureInfo(“”); CultureTypes types = culture.Culture Types;
    // Output the culture information...
C. foreach (CultureInfo culture in
    CultureInfo.GetCultures(CultureTypes.NeutralCultures)) {
    // Output the culture information...}
D. foreach (CultureInfo culture in
    CultureInfo.GetCultures(CultureTypes.ReplacementCultures)) {
    // Output the culture information...}


Answer: A 

You write the following code to call a function from the Win32 Application Programming Interface (API) by using platform invoke.

You write the following code to call a function from the Win32 Application Programming Interface
(API) by using platform invoke.
int rc = MessageBox(hWnd, text, caption, type); You need to define a methon prototype.
Which code segment should you use?

A. [DllImport("user32")]public static extern int MessageBox(int hWnd, String text,
    String caption, uint type);
B. [DllImport("user32")]public static extern int MessageBoxA(int hWnd, String text,
    String caption, uint type);
C. [DllImport("user32")]public static extern int Win32API_User32_MessageBox(
    int hWnd, String text, String caption, uint type);
D. [DllImport(@"C:\WINDOWS\system32\user32.dll")]public static extern int
    MessageBox(int hWnd, String text,

    String caption, uint type);


Answer: A

You are developing a method to decrypt data that was encrypted with the Triple DES Algorithm.

You are developing a method to decrypt data that was encrypted with the Triple DES Algorithm.
The method accepts the following parameters: The byte array to be decrypted, which is named
cipherMessageThe key, which is named keyAn initialization vector, which is named iv You need
to decrypt the message by using the TripleDES class and place the result in a string. Which code
segment should you use?

A. TripleDES^ des = gcnew TripleDESCryptoServiceProvider();des->BlockSize = cipherMessage-
    >Length;
    ICryptoTransform^ crypto = des->CreateDecryptor(key, iv);
    MemoryStream^ cipherStream = gcnew MemoryStream(cipherMessage);
    CryptoStream ^cryptoStream = gcnew CryptoStream(cipherStream, crypto,
    CryptoStreamMode::Read);
    String^ message;StreamReader^ sReader = gcnew StreamReader(cryptoStream);
    message = sReader->ReadToEnd();

B. TripleDES^ des = gcnew TripleDESCryptoServiceProvider();
    des->FeedbackSize = cipherMessage->Length;
    ICryptoTransform^ crypto = des->CreateDecryptor(key, iv);
    MemoryStream^ cipherStream = gcnew MemoryStream(cipherMessage);
    CryptoStream^ cryptoStream = gcnew CryptoStream(cipherStream, crypto,
    CryptoStreamMode::Read);
    String^ message;StreamReader^ sReader = gcnew StreamReader(cryptoStream);
    message = sReader->ReadToEnd();

C. TripleDES^ des = gcnew TripleDESCryptoServiceProvider();
    ICryptoTransform^ crypto = des->CreateDecryptor();
    MemoryStream^ cipherStream = gcnew MemoryStream(cipherMessage);
    CryptoStream^ cryptoStream = gcnew CryptoStream(cipherStream, crypto,
    CryptoStreamMode::Read);String^ message;
    StreamReader^ sReader = gcnew StreamReader(cryptoStream);
    message = sReader->ReadToEnd();

D. TripleDES^ des = gcnew TripleDESCryptoServiceProvider();
    ICryptoTransform^ crypto = des->CreateDecryptor(key, iv);
    MemoryStream^ cipherStream = gcnew MemoryStream(cipherMessage);
    CryptoStream^ cryptoStream = gcnew CryptoStream( cipherStream, crypto,
    CryptoStreamMode::Read);
    String^ message;StreamReader^ sReader = gcnew StreamReader(cryptoStream);
    message = sReader->ReadToEnd();

Answer: D 



 

You write the following code to implement the BraindumpsClass.MyMethod function. Public Class NewClass

You write the following code to implement the BraindumpsClass.MyMethod function.
Public Class NewClass
Public Function MyMethod(ByVal Arg As Integer) As Integer
Return Arg
End FunctionEnd Class You need to call the BraindumpsClass.MyMethod function
dynamically from an unrelated class in your assembly. Which code segment should you use?

A. Dim objNewClass As New NewClassDim objType As Type =
    objNewClass.GetTypeDim objInfo As MethodInfo = _
    objType.GetMethod("MyMethod")Dim objParams() As Object = {1}Dim i As Integer =
    _
    DirectCast(objInfo.Invoke(Me, objParams), Integer)
B. Dim objNewClass As New NewClassDim objType As Type =
    objNewClass.GetTypeDim objInfo As MethodInfo =
    objType.GetMethod("MyMethod")Dim objParams() As Object = {1}Dim i As Integer =
    _
    DirectCast(objInfo.Invoke(objNewClass, objParams), Integer)
C. Dim objNewClass As New NewClassDim objType As Type =
    objNewClass.GetTypeDim objInfo As MethodInfo = _
    objType.GetMethod("NewClass.MyMethod")Dim objParams() As Object = {1}Dim i As
    Integer = _
    DirectCast(objInfo.Invoke(objNewClass, objParams), Integer)
D. Dim objType As Type = Type.GetType("NewClass")Dim objInfo As MethodInfo =
    objType.GetMethod("MyMethod")Dim objParams() As Object = {1}Dim i As Integer =
    _
    DirectCast(objInfo.Invoke(Me, objParams), Integer)


Answer: B 

You are writing a method to compress an array of bytes.

You are writing a method to compress an array of bytes. The bytes to be compressed are passed
to the method in a parameter named document.
You need to compress the contents of the incoming parameter.
Which code segment should you use?


A. MemoryStream inStream = new MemoryStream(document);GZipStream zipStream =
    new GZipStream(inStream,
    CompressionMode.Compress); byte[] result = new
    Byte[document.Length];zipStream.Write(result, 0, result.Length); return result;

B. MemoryStream Stream = new MemoryStream(document);GZipStream zipStream =
    new GZipStream(stream,
    CompressionMode.Compress);zipStream.Write(document, 0,     
    document.Length);zipStream.Close();return stream.ToArray();

C. MemoryStream outStream = new MemoryStream();GZipStream zipStream = new
    GZipStream(outStream,
    CompressionMode.Compress);zipStream.Write(document, 0,     
    document.Length);zipStream.Close();return outStream.ToArray();

D. MemoryStream inStream = new MemoryStream(document);GZipStream zipStream =
    new GZipStream(inStream,
    CompressionMode.Compress); MemoryStream outStream = new MemoryStream();int b;while     
    ((b = zipStream.ReadByte()) != -1) {
    outStream.WriteByte((byte)b);} return outStream.ToArray();



Answer: C

You need to serialize an object of type List in a binary format. The object is named data. Which code segment should you use?

You need to serialize an object of type List<int> in a binary format. The object is named data.
Which code segment should you use?

A. BinaryFormatter formatter = new BinaryFormatter();MemoryStream stream = new 
    MemoryStream();formatter.Serialize(stream, data);
B. BinaryFormatter formatter = new BinaryFormatter();MemoryStream stream = new 
    MemoryStream(); for (int i = 0; i < data.Count, i++) {
    formatter.Serialize(stream, data[i]);}
C. BinaryFormatter formatter = new BinaryFormatter();byte[] buffer = new     
    byte[data.Count];MemoryStream stream = new MemoryStream(buffer, true);
    formatter.Serialize(stream, data);
D. BinaryFormatter formatter = new BinaryFormatter();MemoryStream stream = new     
    MemoryStream();data.ForEach(delegate(int num)
    { formatter.Serialize(stream, data); }
    );

 

Answer: A
 

You are developing an application that receives events asynchronously.

You are developing an application that receives events asynchronously. You create a
WqlEventQuery instance to specify the events and event conditions to which the application must
respond. You also create a ManagementEventWatcher instance to subscribe to events matching
the query. You need to identify the other actions you must perform before the application can
receive events asynchronously. Which two actions should you perform? (Each correct answer
presents part of the solution. Choose two.)

A. Start listening for events by calling the Start method of the ManagementEventWatcher.

B. Set up a listener for events by using the EventArrived event of the ManagementEventWatcher.

C. Use the WaitForNextEvent method of the ManagementEventWatcher to wait for the events.

D. Create an event handler class that has a method that receives an ObjectReadyEventArgs 
    parameter.

E. Set up a listener for events by using the Stopped event of the ManagementEventWatcher.
 
Answer: A, B

You are developing a method to encrypt sensitive data with the Data Encryption Standard (DES) algorithm. Your method accepts the following parameters:

You are developing a method to encrypt sensitive data with the Data Encryption Standard (DES)
algorithm. Your method accepts the following parameters:
The byte array to be encrypted, which is named messageAn encryption key, which is named
keyAn initialization vector, which is named iv You need to encrypt the data. You also need to
write the encrypted data to a MemoryStream object.
Which code segment should you use?

A. Dim objDES As New DESCryptoServiceProviderobjDES.BlockSize =
    message.Length
    Dim objCrypto As ICryptoTransform = obj
    DES.CreateDecryptor(key, iv)
    Dim cipherStream As New MemoryStream
    Dim cryptoStream As New CryptoStream(cipherStream, objCrypto,
    CryptoStreamMode.Write)

B. Dim objDES As New DESCryptoServiceProvider
    Dim objCrypto As ICryptoTransform = objDES.CreateDecryptor(key, iv)Dim
    cipherStream As New MemoryStream
    Dim cryptoStream As New CryptoStream(cipherStream, objCrypto, 
    CryptoStreamMode.Write)
    cryptoStream.Write(message, 0, message.Length)

C. Dim objDES As New DESCryptoServiceProvider
    Dim objCrypto As ICryptoTransform = obj
    DES.CreateDecryptor()
    Dim cipherStream As New MemoryStream
    Dim cryptoStream As New CryptoStream(cipherStream, objCrypto,
    CryptoStreamMode.Write)
    cryptoStream.Write(message, 0, message.Length)

D. Dim objDES As New DESCryptoServiceProvider
    Dim objCrypto As ICryptoTransform = obj
    DES.CreateEncryptor(key, iv)
    Dim cipherStream As New MemoryStream
    Dim cryptoStream As New CryptoStream(cipherStream, objCrypto,
    CryptoStreamMode.Write)
    cryptoStream.Write(message, 0, message.Length)


Answer: D 


You are developing a method that searches a string for a substring. The method will be localized to Italy.

You are developing a method that searches a string for a substring. The method will be localized
to Italy.
Your method accepts the following parameters: The string to be searched, which is named
SearchListThe string for which to search, which is named SearchValue You need to write the
code. Which code segment should you use?

A. Return SearchList.IndexOf(SearchValue)

B. Dim objComparer As CompareInfo = _
    New CultureInfo("it-IT").CompareInfoReturn objComparer.Compare(SearchList,
    SearchValue)

C. Dim objComparer As CompareInfo = _
    New CultureInfo("it-IT").CompareInfoIf SearchList.IndexOf(SearchValue) > 0 Then
    Return TrueElse
    Return FalseEnd If

D. Dim objComparer As CompareInfo = _
    New CultureInfo("it-IT").CompareInfoIf objComparer.IndexOf(SearchList,
    SearchValue) > 0 Then
    Return TrueElse
    Return FalseEnd If


Answer: D 

You are testing a component that serializes the Meeting class instances so that they can be saved to the file system. The Meeting class has the following definition:

You are testing a component that serializes the Meeting class instances so that they can be
saved to the file system. The Meeting class has the following definition:

Public Class Meeting
Private title As String
Public roomNumber As Integer
Public invitees As String()
Public Sub New()End Sub
Public Sub New(ByVal t As String)
title = t
End Sub End Class The component contains a procedure with the following code segment.
Dim myMeeting As New Meeting("Goals") myMeeting.roomNumber = 1100 Dim
attendees As String() = New String(1) {"Braindumps", "Mary"} myMeeting.invitees =
attendees
Dim xs As New XmlSerializer(GetType(Meeting)) Dim writer As New
StreamWriter("C:\Meeting.xml") xs.Serialize(writer, myMeeting) writer.Close() You need to
identify the XML block that is written to the C:\Meeting.xml file as a result of running this
procedure. Which XML block represents the content that will be written to the C:\Meeting.xml file?

A. <?xml version="1.0" encoding="utf-8"?>
    <Meeting xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <title>Goals</title>
    <roomNumber>1100</roomNumber>
    <invitee>Braindumps</invitee>
    <invitee>Mary</invitee>
    </Meeting>
B. <?xml version="1.0" encoding="utf-8"?>
    <Meeting xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <roomNumber>1100</roomNumber>
    <invitees>
    <string>Braindumps</string>
    <string>Mary</string>
    </invitees>
    </Meeting>
C. <?xml version="1.0" encoding="utf-8"?>
    <Meeting xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    title="Goals">
    <roomNumber>1100</roomNumber>
<invitees>
    <string>Braindumps</string>
    <string>Mary</string>
    </invitees>
    </Meeting>
D. <?xml version="1.0" encoding="utf-8"?>
 <Meeting xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <roomNumber>1100</roomNumber>
    <invitees>
    <string>Braindumps</string>
    </invitees>
    <invitees>
    <string>Mary</string>
    </invitees>
    </Meeting>



Answer: B 







You create a method that runs by using the credentials of the end user.

You create a method that runs by using the credentials of the end user. You need to use
Microsoft Windows groups to authorize the user. You must add a code segment that identifies
whether a user is in the local group named Clerk. Which code segment should you use?

A. WindowsIdentity currentUser = WindowsIdentity.GetCurrent();foreach
    (IdentityReference grp in currentUser.Groups) {
    NTAccount grpAccount =
    ((NTAccount)grp.Translate(typeof(NTAccount)));
    isAuthorized = grpAccount.Value.Equals(Environment.MachineName + @”\Clerk”);
    if(isAuthorized) break;}

B. WindowsPrincipal currentUser =
    (WindowsPrincipal)Thread.CurrentPrincipal;isAuthorized = currentUser.IsInRole(“Clerk”);

C. GenericPrincipal currentUser =
    (GenericPrincipal)Thread.CurrentPrincipal;isAuthorized = currentUser.IsInRole(“Clerk”);

D. WindowsPrincipal currentUser =
    (WindowsPrincipal)Thread.CurrentPrincipal;isAuthorized =     
    currentUser.IsInRole(Environment.MachineName);



Answer: B
 

You are creating a class named Age.

You are creating a class named Age.
You need to ensure that the Age class is written such that collections of Age objects can be
sorted. Which code segment should you use?

A. Public Class Age
    Public Value As Integer
  Public Function CompareTo(ByVal obj As Object) As Object
    If TypeOf obj Is Age Then
    Dim _age As Age = CType(obj, Age)
    Return Value.CompareTo(obj)
    End If
    Throw New ArgumentException("object not an Age")
    End FunctionEnd Class

B. Public Class Age
    Public Value As Integer
    Public Function CompareTo(ByVal iValue As Integer) As Object
    Try
    Return Value.CompareTo(iValue)
    Catch
    Throw New ArgumentException ("object not an Age")
    End Try
    End FunctionEnd Class

C. Public Class Age
    Implements IComparable
    Public Value As Integer
    Public Function CompareTo(ByVal obj As Object) As Integer _
    Implements IComparable.CompareTo
    If TypeOf obj Is Age Then
    Dim _age As Age = CType(obj, Age)
    Return Value.CompareTo(_age.Value)
    End If
    Throw New ArgumentException("object not an Age")
    End FunctionEnd Class

D. Public Class Age
    Implements IComparable
    Public Value As Integer
    Public Function CompareTo(ByVal obj As Object) As Integer _
    Implements IComparable.CompareTo
    Try
    Return Value.CompareTo((CType(obj, Age)).Value)
    Catch
    Return -1
    End Try
    End FunctionEnd Class


Answer: C 


You are developing a method that searches a string for a substring.

You are developing a method that searches a string for a substring.  The method will be localized
to Italy.
Your method accepts the following parameters: The string to be searched, which is named
searchListThe string for which to search, which is named searchValue You need to write the
code. Which code segment should you use?

A return searchList.IndexOf(searchValue);
B. CompareInfo comparer =
    new CultureInfo(“it-IT”).CompareInfo; return comparer.Compare(searchList, searchValue);
C. CultureInfo Comparer = new CultureInfo(“it-IT”);if(searchList.IndexOf(searchValue)
    > 0) {
    return true;} else {
    return false;}
D. CompareInfo comparer =
    new CultureInfo(“it-IT”).CompareInfo; if (comparer.IndexOf(searchList,
    searchValue) > 0) {
    return true;} else {
    return false;}
 
Answer: D

You are writing an application that uses isolated storage to store user preferences.

You are writing an application that uses isolated storage to store user preferences. The
application uses multiple assemblies. Multiple users will use this application on the same
computer. You need to create a directory named Preferences in the isolated storage area that is
scoped to the current Microsoft Windows identity and assembly.
Which code segment should you use?

A. Dim objStore As IsolatedStorageFileobjStore =
    IsolatedStorageFile.GetUserStoreForAssemblyobjStore.CreateDirectory("Preferences")

B. Dim objStore As IsolatedStorageFileobjStore =
    IsolatedStorageFile.GetMachineStoreForAssemblyobjStore.CreateDirectory("Preferences")

C. Dim objStore As IsolatedStorageFileobjStore =
    IsolatedStorageFile.GetUserStoreForDomainobjStore.CreateDirectory("Preferences")

D. Dim objStore As IsolatedStorageFileobjStore =
    IsolatedStorageFile.GetUserStoreForApplicationobjStore.CreateDirectory("Preferences")


Answer: A

You are creating a class that performs complex financial calculations.

You are creating a class that performs complex financial calculations. The class contains a
method named GetCurrentRate that retrieves the current interest rate and a variable named
currRate that stores the current interest rate.
You write serialized representations of the class.
You need to write a code segment that updates the currRate variable with the current interest rate
when an instance of the class is deserialized. Which code segment should you use?

A. <OnSerializing> _Friend Sub UpdateValue (ByVal context As StreamingContext)
    currRate = GetCurrentRate()End Sub

B. <OnSerializing> _ Friend Sub UpdateValue(ByVal info As SerializationInfo)
    info.AddValue("currentRate", GetCurrentRate())End Sub

C. <OnDeserializing> _ Friend Sub UpdateValue(ByVal info As SerializationInfo)
    info.AddValue("currentRate", GetCurrentRate())End Sub

D. <OnDeserialized> _Friend Sub UpdateValue (ByVal context As StreamingContext)
    currRate = GetCurrentRate()End Sub


Answer: D
 

Your Braindumps uses an application named Application1 that was compiled by using the .NET Framework version 1.0. The application currently runs on a shared computer on which the .NET Framework versions 1.0 and 1.1 are installed.

Your Braindumps uses an application named Application1 that was compiled by using the .NET
Framework version 1.0. The application currently runs on a shared computer on which the .NET
Framework versions 1.0 and 1.1 are installed.
You need to move the application to a new computer on which the .NET Framework versions 1.1
and 2.0 are installed. The application is compatible with the .NET Framework 1.1, but it is
incompatible with the .NET Framework 2.0. You need to ensure that the application will use the
.NET Framework version 1.1 on the new computer. What should you do?

A. Add the following XML element to the application configuration file.
 <configuration>
    <startup>
    <supportedRuntime version="1.1.4322" />
    <startup>
    </configuration>
B. Add the following XML element to the application configuration file.
    <configuration>
    <runtime>
    <assemblyBinding
    xmlns="urn:schemas-microsoft-com:asm.v1">
    <dependentAssembly>
    <assemblyIdentity name="Application1"
    publicKeyToken="32ab4ba45e0a69a1"
    culture="neutral" />
    <bindingRedirect oldVersion="1.0.3075.0"
    newVersion="1.1.4322.0"/>
    </dependentAssembly>
    </assemblyBinding>
    </runtime>
    </configuration>
C. Add the following XML element to the machine configuration file.
    <configuration>
    <startup>
    <requiredRuntime version="1.1.4322" />
    <startup>
    </configuration>
D. Add the following XML element to the machine configuration file.
    <configuration>
    <runtime>
    <assemblyBinding
    xmlns="urn:schemas-microsoft-com:asm.v1">
    <dependentAssembly>
    <assemblyIdentity name="Application1"
    publicKeyToken="32ab4ba45e0a69a1"
    culture="neutral" />
    <bindingRedirect oldVersion="1.0.3075.0"
    newVersion="1.1.4322.0"/>
    </dependentAssembly>
    </assemblyBinding>
    </runtime>
    </configuration>

Answer: A  


You are developing an application that receives events asynchronously.

You are developing an application that receives events asynchronously.  You create a
WqlEventQuery instance to specify the events and event conditions to which the application must
respond. You also create a ManagementEventWatcher instance to subscribe to events matching
the query. You need to identify the other actions you must perform before the application can
receive events asynchronously. Which two actions should you perform? (Each correct answer
presents part of the solution. Choose two.)


A. Start listening for events by calling the Start method of the
    ManagementEventWatcher.

B. Set up a listener for events by using the EventArrived event of the
    ManagementEventWatcher.

C. Use the WaitForNextEvent method of the ManagementEventWatcher to wait for the
    events.

D. Create an event handler class that has a method that receives an
    ObjectReadyEventArgs parameter.

E. Set up a listener for events by using the Stopped event of the
    ManagementEventWatcher.


Answer: A, B

You are developing a method to decrypt data that was encrypted with the Triple DES Algorithm.

You are developing a method to decrypt data that was encrypted with the Triple DES Algorithm.
The method accepts the following parameters: The byte array to be decrypted, which is named
cipherMessageThe key, which is named keyAn initialization vector, which is named iv You need
to decrypt the message by using the TripleDES class and place the result in a string.
Which code segment should you use?

A. Dim objDES As New TripleDESCryptoServiceProviderobjDES.BlockSize =
    cipherMessage.LengthDim objCrypto As ICryptoTransform = _
    objDES.CreateDecryptor(key, iv)Dim cipherStream As New 
 MemoryStream(cipherMessage)Dim cryptoStream As New CryptoStream( _
    cipherStream, objCrypto, CryptoStreamMode.Read)Dim message As Stringmessage =
    New StreamReader(cryptoStream).ReadToEnd
B. Dim objDES As New TripleDESCryptoServiceProviderobjDES.FeedbackSize =
    cipherMessage.LengthDim objCrypto As ICryptoTransform = _
    objDES.CreateDecryptor(key, iv)Dim cipherStream As New
    MemoryStream(cipherMessage)Dim cryptoStream As New CryptoStream( _
    cipherStream, objCrypto, CryptoStreamMode.Read)Dim message As Stringmessage =
    New StreamReader(cryptoStream).ReadToEnd
C. Dim objDES As New TripleDESCryptoServiceProviderDim objCrypto As
    ICryptoTransform = _
    objDES.CreateDecryptor()Dim cipherStream As New
    MemoryStream(cipherMessage)Dim cryptoStream As New CryptoStream( _
    cipherStream, objCrypto, CryptoStreamMode.Read)Dim message As Stringmessage =
    New StreamReader(cryptoStream).ReadToEnd
D. Dim objDES As New TripleDESCryptoServiceProviderDim objCrypto As
    ICryptoTransform = _
    objDES.CreateDecryptor(key, iv)Dim cipherStream As New
    MemoryStream(cipherMessage)Dim cryptoStream As New CryptoStream( _
    cipherStream, objCrypto, CryptoStreamMode.Read)Dim message As Stringmessage =
    New StreamReader(cryptoStream).ReadToEnd

Answer: D


You are developing an application to perform mathematical calculations.

You are developing an application to perform mathematical calculations. You develop a class
named CalculationValues. You write a procedure named PerformCalculation that operates on an
instance of the class.
You need to ensure that the user interface of the application continues to respond while
calculations are being performed. You need to write a code segment that calls the
PerformCalculation procedure to achieve this goal.
Which code segment should you use?

A. public ref class CalculationValues {}; public ref class Calculator {
    public :
    void PerformCalculation() {} }; public ref class ThreadTest{
    private :
    void DoWork (){
   CalculationValues^ myValues = gcnew CalculationValues();
    Calculator^ calc = gcnew Calculator();
    Thread^ newThread = gcnew Thread(
    gcnew ThreadStart(calc, &Calculator::PerformCalculation));
    newThread->Start(myValues);
    }};
B. public ref class Calculation Values {}; public ref class Calculator {
    public :void PerformCalculation() {}}; public ref class ThreadTest{
    private :
    void DoWork (){
    CalculationValues^ myValues = gcnew CalculationValues();
    Calculator^ calc = gcnew Calculator();
    ThreadStart^ delStart = gcnew
    ThreadStart(calc, &Calculator::PerformCalculation);
    Thread^ newThread = gcnew Thread(delStart);
    if (newThread->IsAlive) {
    newThread->Start(myValues);
    }
    }};
C. public ref class Calculation Values {}; public ref class Calculator {
    public :
    void PerformCalculation(CalculationValues^ values) {} }; public ref class ThreadTest{
    private :
    void DoWork (){
    CalculationValues^ myValues = gcnew CalculationValues();
    Calculator^ calc = gcnew Calculator();
    Application::DoEvents();
    calc->PerformCalculation(myValues);
    Application::DoEvents();
    }};
D. public ref class Calculation Values {}; public ref class Calculator {
    public :
    void PerformCalculation(Object^ values) {} }; public ref class ThreadTest{
    private :
    void DoWork (){
    CalculationValues^ myValues = gcnew CalculationValues();
    Calculator^ calc = gcnew Calculator();
    Thread^ newThread = gcnew Thread(
    gcnew ParameterizedThreadStart(calc,
    &Calculator::PerformCalculation));
    newThread->Start(myValues);
    }};

Answer: D

You are developing a utility screen for a new client application.

You are developing a utility screen for a new client application. The utility screen displays a
thermometer that conveys the current status of processes being carried out by the application.
You need to draw a rectangle on the screen to serve as the background of the thermometer as
shown in the exhibit. The rectangle must be filled with gradient shading.
Which code segment should you choose?

Exhibit:
  

A. Rectangle rectangle = new Rectangle(10, 10, 450, 25); LinearGradientBrush
    rectangleBrush =
    new LinearGradientBrush(rectangle, Color.AliceBlue,
    Color.CornflowerBlue,
    LinearGradientMode.ForwardDiagonal); Pen rectanglePen = new Pen(rectangleBrush);
    Graphics g = this.CreateGraphics(); g.DrawRectangle(rectanglePen, rectangle);
B. Rectangle rectangle = new Rectangle(10, 10, 450, 25); LinearGradientBrush
    rectangleBrush =
    new LinearGradientBrush(rectangle, Color.AliceBlue,
    Color.CornflowerBlue,
    LinearGradientMode.ForwardDiagonal); Pen rectanglePen = new Pen(rectangleBrush);
    Graphics g = this.CreateGraphics(); g.FillRectangle(rectangleBrush, rectangle);
C. RectangleF rectangle = new RectangleF(10f, 10f, 450f, 25f); Point[] points = new
    Point[] {new Point(0, 0),
    new Point(110, 145)}; LinearGradientBrush rectangelBrush =
    new LinearGradientBrush(rectangle, Color.AliceBlue,
    Color.CornflowerBlue,
    LinearGradientMode.ForwardDiagonal); Pen rectanglePen = new Pen(rectangleBrush);
    Graphics g = this.CreateGraphics(); g.DrawPolygon(rectanglePen, points);
D. RectangleF rectangle = new RectangleF(10f, 10f, 450f, 25f); SolidBrush
    rectangleBrush =
    new SolidBrush(Color.AliceBlue); Pen rectanglePen = new Pen(rectangleBrush);
    Graphics g = this.CreateGraphics(); g.DrawRectangle(rectangleBrush, rectangle);
    
Answer: B

You need to return the contents of an isolated storage file as a string. The file is machine-scoped and is named Settings.dat. Which code segment should you use?

You need to return the contents of an isolated storage file as a string. The file is machine-scoped
and is named Settings.dat. Which code segment should you use?


A. Dim objStream As IsolatedStorageFileStreamobjStream = New
    IsolatedStorageFileStream( _
    "Settings.dat", FileMode.Open)Dim result As String = New
    StreamReader(objStream).ReadToEnd

B. Dim objFile As IsolatedStorageFileobjFile =
    IsolatedStorageFile.GetMachineStoreForAssemblyDim objStream As
    IsolatedStorageFileStreamobjStream = New IsolatedStorageFileStream( _
    "Settings.dat", FileMode.Open, objFile)Dim result As String = New
    StreamReader(objStream).ReadToEnd

C. Dim objStream As IsolatedStorageFileStreamobjStream = New
    IsolatedStorageFileStream( _
    "Settings.dat", FileMode.Open)Dim result As String objStream.toString

D. Dim objFile As IsolatedStorageFileobjFile =
    IsolatedStorageFile.GetMachineStoreForAssemblyDim objStream As
    IsolatedStorageFileStreamobjStream = New IsolatedStorageFileStream( _
    "Settings.dat", FileMode.Open, objFile)Dim result As String = objStream.ToString

Answer: B 

You need to write a code segment that transfers the contents of a byte array named dataToSend by using a NetworkStream object named netStream. You need to use a cache of size 8,192 bytes. Which code segment should you use?

You need to write a code segment that transfers the contents of a byte array named dataToSend
by using a NetworkStream object named netStream. You need to use a cache of size 8,192
bytes. Which code segment should you use?

A. MemoryStream memStream = new
    MemoryStream(8192);memStream.Write(dataToSend, 0, (int) netStream.Length);

B. MemoryStream memStream = new
    MemoryStream(8192);netStream.Write(dataToSend, 0, (int) memStream.Length);

C. BufferedStream bufStream = new BufferedStream(netStream, 8192);
    bufStream.Write(dataToSend, 0, dataToSend.Length);

D. BufferedStream bufStream = new BufferedStream(netStream);
    bufStream.Write(dataToSend, 0, 8192);

Answer: C
 

You develop a service application named PollingService that periodically calls long-running procedures.

You develop a service application named PollingService that periodically calls long-running  procedures. These procedures are called from the DoWork method.
You use the following service application code: partial class PollingService :
ServiceBase {
bool blnExit = false; public PollingService() {}
protected override void OnStart(string[] args) {
do {
DoWork();
} while (!blnExit);
}
protected override void OnStop() {
blnExit = true;
}
private void DoWork() {
...
} }
When you attempt to start the service, you receive the following error message: Could not start
the PollingService service on the local computer. Error 1053: The service did not respond to the
start or control request in a timely fashion. You need to modify the service application code so
that the service starts properly. What should you do?


A. Move the loop code into the constructor of the service class from the OnStart method.

B. Drag a timer component onto the design surface of the service. Move the calls to the long-
running procedure from the OnStart method into the Tick event procedure of the timer, set
the Enabled property of the timer to True, and call the Start method of the timer in the
OnStart method.

C. Add a class-level System.Timers.Timer variable to the service class code. Move the call to
the DoWork method into the Elapsed event procedure of the timer, set the Enabled property
of the timer to True, and call the Start method of the timer in the OnStart method.

D. Move the loop code from the OnStart method into the DoWork method.


Answer: C