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

Question: You are defining a class named CompanyClass that contains several child objects. CompanyClass contains a method named ProcessChildren that performs actions on the child objects. CompanyClass objects will be serializable. You need to ensure that the ProcessChildren method is executed after the CompanyClass object and all its child objects are reconstructed. Which two actions should you perform? (Each correct answer presents part of the solution. Choose two.)

  1. Apply the OnDeserializing attribute to the ProcessChildren method.
  2. Specify that CompanyClass implements the IDeserializationCallback interface.
  3. Specify that CompanyClass inherits from the ObjectManager class.
  4. Apply the OnSerialized attribute to the ProcessChildren method.
  5. Create a GetObjectData method that calls ProcessChildren.
  6. Create an OnDeserialization method that calls ProcessChildren.

Correct Answer: 2 & 6


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

  1. MemoryStream memStream = new MemoryStream(8192);
    memStream.Write(dataToSend, 0, (int) netStream.Length);
  2. MemoryStream memStream = new MemoryStream(8192);
    netStream.Write(dataToSend, 0, (int) memStream.Length);
  3. BufferedStream bufStream = new BufferedStream(netStream, 8192);
    bufStream.Write(dataToSend, 0, dataToSend.Length);
  4. BufferedStream bufStream = new BufferedStream(netStream);
    bufStream.Write(dataToSend, 0, 8192);

Correct Answer: 3


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

  1. string result = null;
    StreamReader reader = new StreamReader("Message.txt");
    result = reader.Read().ToString();
  2. string result = null;
    StreamReader reader = new StreamReader("Message.txt");
    result = reader.ReadToEnd();
  3. string result = string.Empty;
    StreamReader reader = new StreamReader("Message.txt");
    while(!reader.EndOfStream) {
    result += reader.ToString();
    }
  4. string result = null;
    StreamReader reader = new StreamReader("Message.txt");
    result = reader.ReadLine();

Correct Answer: 2


Question: You are writing an application that uses SOAP to exchange data with other applications. You use a Department class that inherits from ArrayList to send objects to another application. The Department object is named dept. You need to ensure that the application serializes the Department object for transport by using SOAP. Which code should you use?

  1. SoapFormatter formatter = new SoapFormatter();
    byte[] buffer = new byte[dept.Capacity];
    MemoryStream stream = new MemoryStream(buffer);
    foreach (object o in dept) {formatter.Serialize(stream, o);}
  2. SoapFormatter formatter = new SoapFormatter();
    byte[] buffer = new byte[dept.Capacity];
    MemoryStream stream = new MemoryStream(buffer);
    formatter.Serialize(stream, dept);
  3. SoapFormatter formatter = new SoapFormatter();
    MemoryStream stream = new MemoryStream();
    foreach (object o in dept) { Formatter.Serialize(stream, o);}
  4. SoapFormatter formatter = new SoapFormatter();
    MemoryStream stream = new MemoryStream();
    formatter.Serialize(stream, dept);

Correct Answer: 4


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

  1. BinaryFormatter formatter = new BinaryFormatter();
    MemoryStream stream = new MemoryStream();
    formatter.Serialize(stream, data);
  2. BinaryFormatter formatter = new BinaryFormatter();
    MemoryStream stream = new MemoryStream();
    for (int i = 0; i < data.Count, i++) {
    formatter.Serialize(stream, data[i]);}
  3. BinaryFormatter formatter = new BinaryFormatter();
    byte[] buffer = new byte[data.Count];
    MemoryStream stream = new MemoryStream(buffer, true);
    formatter.Serialize(stream, data);
  4. BinaryFormatter formatter = new BinaryFormatter();
    MemoryStream stream = new MemoryStream();
    data.ForEach(delegate(int num)
    { formatter.Serialize(stream, data); }
    );

Correct Answer: 1

Tagged . Bookmark the permalink.

Leave a Reply