Ensurepass

QUESTION 61

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

B. string dateString = DateTime.Today.Month.ToString("es-MX");

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

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

Correct Answer: D


QUESTION 62

You write the following custom exception class named CustomException.

public class CustomException : ApplicationException

{

public static int COR_E_ARGUMENT = unchecked((int)0x80070057); public CustomException(string msg) : base(msg)

{

HResult = COR_E_ARGUMENT;

}

}

You need to write a code segment that will use the CustomException class to immediately return control to the COM caller. You also need to ensure that the caller has access to the error code.

Which code segment should you use?

A. return Marshal.GetExceptionForHR(CustomException.COR_E_ARGUMENT);

B. return CustomException.COR_E_ARGUMENT;

C. Marshal.ThrowExceptionForHR(CustomException.COR_E_ARGUMENT);

D. throw new CustomException("Argument is out of bounds");

Correct Answer: D


QUESTION 63

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 = new ArrayList(); lock (al.SyncRoot)

{

return al;

}

B. ArrayList al = new ArrayList(); lock (al.SyncRoot.GetType())

{

return al;

}

C. ArrayList al = new ArrayList(); Monitor.Enter(al); Monitor.Exit(al);

return al;

D. ArrayList al = new ArrayList();

ArrayList sync_al = ArrayList.Synchronized(al); return sync_al;

Correct Answer: D


QUESTION 64

You are developing an application to assist the user in conducting electronic surveys. The survey consists of 25 true-or-false
QUESTION s. 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 = new BitVector32(1);

B. BitVector32 answers = new BitVector32(-1);

C. BitArray answers = new BitArray(1);

D. BitArray answers = new BitArray(-1);

Correct Answer: B


QUESTION 65

You need to read the entire contents of a file named Message.txt into a single string variable. Which code segment should you use?

A. string result = null;

StreamReader reader = new StreamReader("Message.txt"); result = reader.Read().ToString();

B. string result = null;

StreamReader reader = new StreamReader("Message.txt"); result = reader.ReadToEnd();

C. string result = string.Empty;

StreamReader reader = new StreamReader("Message.txt"); while(!reader.EndOfStream)

{

result += reader.ToString();

}

D. string result = null;

StreamReader reader = new StreamReader("Message.txt"); result = reader.ReadLine();

Correct Answer: B


QUESTION 66

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 int Value;

public object CompareTo(object obj)

{

if (obj is Age)

{

Age_age = (Age) obj;

return Value.ComapreTo(obj);

}

throw new ArgumentException("object not an Age");

}

}

B. public class Age

{

public int Value;

public object CompareTo(int iValue)

{

try { return Value.ComapreTo(iValue); }

catch { throw new ArgumentException("object not an Age"); } } }

C. public class Age : IComparable

{

public int Value;

public int CompareTo(object obj)

{

if (obj is Age)

{

Age_age = (Age) obj;

return Value.ComapreTo(age.Value);

}

throw new ArgumentException("object not an Age");

}

}

D. public class Age : IComparable

{

public int Value;

public int CompareTo(object obj)

{

try { return Value.ComapreTo(((Age) obj).Value); } catch { return -1; }

}

}

Correct Answer: C


QUESTION 67

You are developing a class library. Portions of your code need to access system environment variables. You need to force a runtime SecurityException only when callers that are higher in the call stack do not have the necessary permissions. Which call method should you use?

A. set.Demand();

B. set.Deny();

C. set.Assert();

D. set.PermitOnly();

Correct Answer: A


QUESTION 68

You write the following code to implement the CompanyClass.MyMethod function.

public class CompanyClass

{

public int MyMethod(int arg)

{

return arg;

}

}

You need to call the CompanyClass.MyMethod function dynamically from an unrelated class in your assembly. Which code segment should you use?

A. CompanyClass myClass = new CompanyClass(); Type t = typeof(CompanyClass);

MethodInfo m = t.GetMethod("MyMethod"); int i = (int)m.Invoke(this, new object[] { 1 });

B. CompanyClass myClass = new CompanyClass(); Type t = typeof(CompanyClass);

MethodInfo m = t.GetMethod("MyMethod");

int i = (int) m.Invoke(myClass, new object[] { 1 });

C. CompanyClass myClass = new CompanyClass(); Type t = typeof(CompanyClass);

MethodInfo m = t.GetMethod("CompanyClass.MyMethod"); int i = (int)m.Invoke(myClass, new object[] { 1 });

D. Type t = Type.GetType("CompanyClass"); MethodInfo m = t.GetMethod("MyMethod"); int i = (int)m.Invoke(this, new object[] { 1 });

Correct Answer: B


QUESTION 69

You are creating an application that lists processes on remote computers. The application requires a method that performs the following tasks:

稟ccept the remote computer name as a string parameter named strComputer.

稲eturn 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 = new ArrayList();

Process[] procs = Process.GetProcessesByName(strComputer); foreach (Process proc in procs)

{

al.Add(proc);

}

B. ArrayList al = new ArrayList();

Process[] procs = Process.GetProcesses(strComputer); foreach (Process proc in procs)

{

al.Add(proc);

}

C. ArrayList al = new ArrayList();

Process[] procs = Process.GetProcessesByName(strComputer); foreach (Process proc in procs)

{

al.Add(proc.ProcessName);

}

D. ArrayList al = new ArrayList();

Process[] procs = Process.GetProcesses(strComputer); foreach (Process proc in procs)

{

al.Add(proc.ProcessName);

}

Correct Answer: D


QUESTION 70

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 cipherMessage The key, which is named key

An 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 = new TripleDESCryptoServiceProvider(); ICryptoTransform crypto = des.CreateDecryptor();

MemoryStream cipherStream = new MemoryStream(cipherMessage); CryptoStream cryptoStream = new CryptoStream(cipherStream, crypto, CryptoStreamMode.Read); string message;

message = new StreamReader(cryptoStream).ReadToEnd();

B. TripleDES des = new TripleDESCryptoServiceProvider(); ICryptoTransform crypto = des.CreateDecryptor(key, iv);

MemoryStream cipherStream = new MemoryStream(cipherMessage); CryptoStream cryptoStream = new CryptoStream(cipherStream, crypto, CryptoStreamMode.Read); string message;

message = new StreamReader(cryptoStream).ReadToEnd();

C. TripleDES des = new TripleDESCryptoServiceProvider(); des.BlockSize = cipherMessage.Length; ICryptoTransform crypto = des.CreateDecryptor(key, iv);

MemoryStream cipherStream = new MemoryStream(cipherMessage); CryptoStream cryptoStream = new CryptoStream(cipherStream, crypto, CryptoStreamMode.Read); string message;

message = new StreamReader(cryptoStream).ReadToEnd();

D. TripleDES des = new TripleDESCryptoServiceProvider(); des.FeedbackSize = cipherMessage.Length; ICryptoTransform crypto = des.CreateDecryptor(key, iv);

MemoryStream cipherStream = new MemoryStream(cipherMessage); CryptoStream cryptoStream = new CryptoStream(cipherStream, crypto, CryptoStreamMode.Read); string message;

message = new StreamReader(cryptoStream).ReadToEnd();

Correct Answer: B

Download Latest 70-536 Real Free Tests , help you to pass exam 100%.

Comments are closed.