Exam 70-536 : .NET Framework Application Development Foundation Part – 5

Question: 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?

  1. private void PerformCalculation() {...}
    private void DoWork(){
    CalculationValues myValues = new CalculationValues();
    Thread newThread = new Thread(new ThreadStart(PerformCalculation));
    newThread.Start(myValues);
    }
  2. private void PerformCalculation() {...}
    private void DoWork(){
    CalculationValues myValues = new CalculationValues();
    ThreadStart delStart = new ThreadStart(PerformCalculation);
    Thread newThread = new Thread(delStart);
    if (newThread.IsAlive)
    {
    newThread.Start(myValues);
    }
    }
  3. private void PerformCalculation (CalculationValues values) {...}
    private void DoWork(){
    CalculationValues myValues = new CalculationValues();
    Application.DoEvents();
    PerformCalculation(myValues);
    Application.DoEvents();
    }
  4. private void PerformCalculation(object values) {...}
    private void DoWork(){
    CalculationValues myValues = new CalculationValues();
    Thread newThread = new Thread(new ParameterizedThreadStart(PerformCalculation));
    newThread.Start(myValues);
    }

Correct Answer: 4


Question: You are writing a method to compress an array of bytes. The array is passed to the method in a parameter named document. You need to compress the incoming array of bytes and return the result as an array of bytes. Which code segment should you use?

  1. MemoryStream strm = new MemoryStream(document);
    DeflateStream deflate = new DeflateStream(strm, CompressionMode.Compress);
    byte[] result = new byte[document.Length];
    deflate.Write(result, 0, result.Length);
    return result;
  2. MemoryStream strm = new MemoryStream(document);
    DeflateStream deflate = new DeflateStream(strm, CompressionMode.Comress);
    deflate.Write(docemtn, 0, document.Length);
    deflate.Close();
    return strm.ToArray();
  3. MemoryStream strm = new MemoryStream();
    DeflateStream deflate = new DeflateStream(strm, CompressionMode.Compress);
    deflate.Write(decument, 0, decument.Length);
    deflate.Close();
    return strm.ToArray();
  4. MemoryStream inStream = new MemoryStream(document);
    DeflateStream deflate = new DeflateStream(inStream, CompressionMode.Compress);
    MemoryStream outStream = new MemoryStream();
    int b;
    while ((b = deflate.ReadByte()) ! = -1) {
    outStream.WriteByte((byte)b);
    }
    return outStream.ToArray();

Correct Answer: 3


Question: 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?

  1. 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");
    }
    }
  2. public class Age {
    public int Value;
    public object CompareTo(int iValue) {
    try {
    return Value.ComapreTo(iValue);
    } catch {
    throw new ArgumentException("object not an Age");
    }
    }
    }
  3. 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");
    }
    }
  4. public class Age : IComparable {
    public int Value;
    public int CompareTo(object obj) {
    try {
    return Value.ComapreTo(((Age) obj).Value);
    } catch {
    return -1;
    }
    }
    }

Correct Answer: 3


Question: 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 “Company” You also need to ensure that the code segment simultaneously facilitates uninterrupted execution of the application. Which code segment should you use?

  1. Debug.Assert(fName == "Company", "Test Failed: ", fName);
  2. Debug.WriteLineIf(fName != "Company", fName, "Test Failed");
  3. if (fName != "Company") {
    Debug.Print("Test Failed: ");
    Debug.Print(fName);
    }
  4. if (fName != "Company") {
    Debug.WriteLine("Test Failed: ");
    Debug.WriteLine (fName);
    }

Correct Answer: 2


Question: 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?

  1. EventLog myLog = new EventLog("Application", ".");
    foreach (EventLogEntry entry in myLog.Entries)
    {
    if (entry.Source == "MySource")
    {
    PersistToDB(entry);
    } }
  2. EventLog myLog = new EventLog("Application", ".");
    myLog.Source = "MySource";
    foreach (EventLogEntry entry in myLog.Entries)
    {
    if (entry.EntryType == (EventLogEntryType.Error & EventLogEntryType.Warning))
    {
    PersistToDB(entry);
    } }
  3. EventLog myLog = new EventLog("Application", ".");
    foreach (EventLogEntry entry in myLog.Entries)
    {
    if (entry.Source == "MySource")
    {
    if (entry.EntryType == EventLogEntryType.Error ||
    entry.EntryType == EventLogEntryType.Warning)
    {
    PersistToDB(entry);
    }
    }
    }
  4. EventLog myLog = new EventLog("Application", ".");
    myLog.Source = "MySource";
    foreach (EventLogEntry entry in myLog.Entries)
    {
    if (entry.EntryType == EventLogEntryType.Error ||
    entry.EntryType == EventLogEntryType.Warning)
    {
    PersistToDB(entry);
    }

Correct Answer: 3

Tagged . Bookmark the permalink.

Leave a Reply