Tuesday

70-536 Dumps Questions: TS: MICROSOFT .NET FRAMEWORK 2013

                             PART 2 OF 10 (WITH EXPLANATION)

QUESTION 1


You are developing a class library that will open the network socket connections to computers on the network.
You will deploy the class library to the global assembly cache and grant it full trust. You write the following code to ensure usage of the socket connections.

SocketPermission permission = new SocketPermission(PermissionState.Unrestricted);
permission.Assert();

Some of the applications that use the class library might not have the necessary permissions to open the network socket connections. You need to cancel the assertion. Which code segment should you use?

A. CodeAccessPermission.RevertAssert();
B. CodeAccessPermission.RevertDeny();
C. permission.Deny();
D. permission.PermitOnly();

Correct Answer: A

Explanation: CodeAccessPermission.ReverAssert() should be used to undo a previous Assert call.


QUESTION 2

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 void StartService(string serverName){
02: ServiceController crtl = new
03: ServiceController("FileService");
04: if (crtl.Status == ServiceControllerStatus.Stopped){
05: }
06: }
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);

Correct Answer: BE

Explanation: The ServiceController is capable of controller services on other computers, the MachineName should be specified. The service should be started with the Start() method if it is in the stopped state.
Setting the ServiceName to the machine name is incorrect.
No such property as SiteName
Continue cannot re-start a stopped service only a paused one.
ExecuteCommand is used to fire a custom command on the service.

QUESTION 3

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);

Correct Answer: B

Explanation: To check the role membership of the current windows user, user the IsInRole() method of the WindowsPrincipal in the current thread.

QUESTION 4

You need to write a code segment that performs the following tasks:
· Retrieve the name of each paused service.
· Passes the name of each paused service to the Add method of Collection1.
Which code segment should you use?

A. ManagementObjectSearcher searcher =
new ManagementObjectSearcher("Select * from Win32_Service where State = 'Paused'");
foreach (ManagementObject svc in searcher.Get())
{
Collection1.Add(svc["DisplayName"]);
}

B. ManagementObjectSearcher searcher =
new ManagementObjectSearcher("Select * from Win32_Service", "State ='Paused'");
foreach (ManagementObject svc in searcher.Get())
{
Collection1.Add(svc["DisplayName"]);
}

C. ManagementObjectSearcher searcher =
new ManagementObjectSearcher("Select * from Win32_Service");
foreach (ManagemetnObject svc in searcher.Get())
{i
f ((string) svc["State"] == "'Paused'")
{
Collection1.Add(svc["DisplayName"]);
}}

D. ManagementObjectSearcher searcher = new ManagementObjectSearcher();
searcher.Scope = new ManagementScope("Win32_Service");
foreach (ManagementObject svc in searcher.Get())
{i
f ((string)svc["State"] == "Paused")
{
Collection1.Add(svc["DisplayName"]);
}}

Correct Answer: A

QUESTION 5

You need to write a code segment that transfers the first 80 bytes from a stream variable named stream1 into a new byte array named byteArray. You also need to ensure that the code segment assigns the number of bytes that are transferred to an integer variable named bytesTransferred.
Which code segment should you use?

A. bytesTransferred = stream1.Read(byteArray, 0, 80);
B. for (int i = 0; i < 80; i++)
{
stream1.WriteByte(byteArray[i]);
bytesTransferred = i;
if (!stream1.CanWrite)
{
break;
}}

C. while (bytesTransferred < 80)
{
stream1.Seek(1, SeekOrigin.Current);
byteArray[bytesTransferred++] = Convert.ToByte(stream1.ReadByte()); }

D. stream1.Write(byteArray, 0, 80);
bytesTransferred = byteArray.Length;

Correct Answer: A

Explanation: The Read() method accepts a byte array and the start position and number of bytes to read as parameters.

QUESTION 6

You create an application that stores information about your customers who reside in various regions. You are developing internal utilities for this application. You need to gather regional information about your customers in Canada.
Which code segment should you use?

A. foreach (CultureInfo culture in CultureInfo.GetCultures(CultureTypes.SpecificCultures))
{/
/ Output the region information...
}

B. CultureInfo cultureInfo = new CultureInfo("CA");
// Output the region information...

C. RegionInfo regionInfo = new RegionInfo("CA");
// Output the region information...

D. RegionInfo regionInfo = new RegionInfo("");
if(regionInfo.Name == "CA")
{/
/ Output the region information...
}

Correct Answer: C

Explanation: The RegionInfo class can be used to get information about a region.

QUESTION 7

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 = new SslStream(client.GetStream());
ssl.AuthenticateAsServer(certificate,false, SslProtocols.None, true);

B. SslStream ssl = new SslStream(client.GetStream());
ssl.AuthenticateAsServer(certificate,false, SslProtocols.Ssl3, true);

C. SslStream ssl = new SslStream(client.GetStream());
ssl.AuthenticateAsServer(certificate,false, SslProtocols.Ssl2, true);

D. SslStream ssl = new SslStream(client.GetStream());
ssl.AuthenticateAsServer(certificate,false, SslProtocols.Tls, true);

Correct Answer: D

QUESTION 8

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 = new StringReader(message);
Process(reader.ReadToEnd());
reader.Close();

B. StringReader reader = new StringReader(message);
while (reader.Peek() != -1)
{
string line = reader.Read().ToString();
Process(line);
}
reader.Close();

C. StringReader reader = new StringReader(message);
Process(reader.ToString());
reader.Close();

D. StringReader reader = new StringReader(message);
while (reader.Peek() != -1)
{
Process(reader.ReadLine());
}
reader.Close();

Correct Answer: D

Explanation: StringReader.ReadLine() allows for lines to be read line by line.

QUESTION 9

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 message
· An encryption key, which is named key
· An 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. DES des = new DESCryptoServiceProvider();
des.BlockSize = message.Length;
ICryptoTransform crypto = des.CreateEncryptor(key, iv);
MemoryStream cipherStream = new MemoryStream();
CryptoStream cryptoStream = new CryptoStream(cipherStream, crypto, CryptoStreamMode.Write);
cryptoStream.Write(message, 0, message.Length);

B. DES des = new DESCryptoServiceProvider();
ICryptoTransform crypto = des.CreateDecryptor(iv, key);
MemoryStream cipherStream = new MemoryStream();
CryptoStream cryptoStream = new CryptoStream(cipherStream, crypto, CryptoStreamMode.Write);
cryptoStream.Write(message, 0, message.Length);

C. DES des = new DESCryptoServiceProvider();
ICryptoTransform crypto = des.CreateEncryptor();
MemoryStream cipherStream = new MemoryStream();
CryptoStream cryptoStream = new CryptoStream(cipherStream, crypto, CryptoStreamMode.Write);
cryptoStream.Write(message, 0, message.Length);

D. DES des = new DESCryptoServiceProvider();
ICryptoTransform crypto = des.CreateEncryptor(key, iv);
MemoryStream cipherStream = new MemoryStream();
CryptoStream cryptoStream = new CryptoStream(cipherStream, crypto, CryptoStreamMode.Write);
cryptoStream.Write(message, 0, message.Length);

Correct Answer: D

Explanation: Use the DesCryptoServiceProvider to create a new encryptor.Create a CryptoStream that encrypt directly to the MemoryStream and call the Write() method to perform the encryption.

QUESTION 10

You are creating a new security policy for an application domain. You write the following lines of code.
PolicyLevel policy = PolicyLevel.CreateAppDomainLevel();
PolicyStatement noTrustStatement = new PolicyStatement(policy.
GetNamedPermissionSet("Nothing"));
PolicyStatement fullTrustStatement = new 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 = new FirstMatchCodeGroup(new AllMembershipCondition(), noTrustStatement);
CodeGroup group2 = new UnionCodeGroup(new ZoneMembershipCondition(SecurityZone.Trusted),
fullTrustStatement);
group1.AddChild(group2);

B. CodeGroup group = new FirstMatchCodeGroup(new AllMembershipCondition(), noTrustStatement);

C. CodeGroup group = new UnionCodeGroup(new ZoneMembershipCondition(SecurityZone.Trusted),
fullTrustStatement);

D. CodeGroup group1 = new FirstMatchCodeGroup(new ZoneMembershipCondition(SecurityZone.Trusted),
fullTrustStatement);
CodeGroup group2 = new UnionCoderoup(new AllMembershipCondition(), noTrustStatement);
group1.AddChild(group2);

Correct Answer: A

No comments:

Post a Comment