70-536 Microsoft .NET Framework Application Development Foundation

Implementing serialization and input/output functionality in a .NET Framework application

 

Q1: 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;

 

Answer: A

 

Q2: 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.)

 

A. Apply the OnDeserializing attribute to the ProcessChildren method.

 

B. Specify that CompanyClass implements the IDeserializationCallback interface.

 

C. Specify that CompanyClass inherits from the ObjectManager class.

 

D. Apply the OnSerialized attribute to the ProcessChildren method.

 

E. Create a GetObjectData method that calls ProcessChildren.

 

F. Create an OnDeserialization method that calls ProcessChildren.

 

 

Answer: B, F

 

 

Q3: 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

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

 

Answer: B

 

– Nikhil Kumar
For All Dumps visit my blog and leave commets also...
www.dotnetask.blog.co.in