Tuesday, August 25, 2009

70-536 MCTS .NET Foundations #27

Hey Now,

Please feel free to check out my MCTS 70-536 reference page on Chris Catto.com. It’s a page with a summary of all of my posts.
As I study for this test I thought this would be good to post on to learn the content & others would be able to view & comment on it.

This content below is from some practice questions from the internet & not sure the answers are correct. There were over 200 questions & some duplicates, I hope to study all of them. I’ve also added some of my notes to these so any line starting with K8 (my nickname, first syllable of Catt o ) are my comments.

Thx,

Catto

Q#111 – Q#120

 

Question: 111

You are developing a fiscal report for Company.com. Company.com has a main office in the United States and a satellite office in the UK. 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. Dim DTFormat As DateTimeFormatInfo = _ New CultureInfo("es-MX",

False).DateTimeFormatDim DT As New DateTime( _ DateTime.Today.Year,

DateTime.Today.Month, DateTime.Today.Day)Dim strDate As String = _

DT.ToString(DTFormat.LongDatePattern)

B. Dim objCalendar As Calendar = _ New CultureInfo("es-MX", False).CalendarDim DT As New

DateTime( _ DateTime.Today.Year, DateTime.Today.Month, DateTime.Today.Day)Dim

strDate As String = DT.ToString

C. Dim strDate As String = _ DateTimeFormatInfo.CurrentInfo.GetMonthName( _

DateTime.Today.Month)

D. Dim strDate As String = _ DateTime.Today.Month.ToString("es-MX")

Answer: A

K8 – Good Old DTFormat

Question: 112

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...}

Answer: C

K8 – Q: regional info A: RegionInfo

Question: 113

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 = gcnew BinaryFormatter();MemoryStream^ stream = gcnew
MemoryStream();
formatter->Serialize(stream, data);

B. BinaryFromatter formatter = gcnew BinaryFormatter();MemoryStream^ stream = gcnew
MemoryStream();
for (int i = 0; i < data->Count; i++) {
formatter->Serialize(stream, data[i]);}

C. BinaryFormatter^ formatter = gcnew BinaryFormatter();array<Byte>^ buffer = gcnew
array<Byte>(data->Count);MemoryStream^ stream = gcnew MemoryStream(buffer, true);
formatter->Serialize(stream, data);

D. BinaryFormatter^ formatter = gcnew BinaryFormatter();
MemoryStream^ stream = gcnew
MemoryStream();Capture c(formatter, stream);data->ForEach(gcnew Action<int>(%c, &Capture::Action));

Answer: A

K8 – no for loop needed

Question: 114

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

Answer: D

K8 - SslProtocols.Tls Tls

Q: Transmit Layer Security A: Tls

Question: 115

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.As sert, _

Flags:=SecurityPermissionFlag.UnmanagedCode) _>

D. <SecurityPermission( _

SecurityAction.Deny, _

Flags:=SecurityPermissionFlag.UnmanagedCode) _>

Answer: A

K8 – Q: Level of trust COM A: SecurityAction.Deman

Question: 116

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

Answer: D

K8 – Break the message into individual lines A: use Peek()

Question: 117

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

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

C. DES des = new DESCryptoServiceProvider();ICryptoTrans form 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();
ICryptoTrans form crypto =
des.CreateEncryptor(key, iv);
MemoryStream cipherStream = new MemoryStream();
CryptoStream cryptoStream = new CryptoStream(cipherStream, crypto, CryptoStreamMode.Write);
cryptoStream.Write(message, 0, message.Length);

Answer: D

K8 – Q: Encrypt using DES A: des.CreateDecryptor(key, iv); & MemoryStream();

Question: 118

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 ZoneMembershipCondition(SecurityZone.Trusted),
fullTrustStatement);
CodeGroup group2 = new UnionCodegroup( new AllMembershipCondition(),
noTrustStatement); group1.AddChild(group2);

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

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

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

Answer: B

K8 – 2 code groups needed. First use AllMembershipCondition to all

Question: 119

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

K8 Add a class level timer

Question: 120

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

K8 – Transfer contents of byte array with cashe limit use BufferedsTream(netStream, 8192)

No comments: