Latest MCTS 70-536 Real Exam Download 11-20

Ensurepass

QUESTION 11

You write the following code:

public delegate void FaxDocs(object sender, FaxArgs args);

You need to create an event that will invoke FaxDocs. Which code segment should you use?

A. public static event FaxDocs Fax;

B. public static event Fax FaxDocs;

C. public class FaxArgs : EventArgs

{

private string coverPageInfo; public FaxArgs(string coverInfo)

{

this.coverPageInfo = coverPageInfo;

}

public string CoverPageInformation

{

get { return this.coverPageInfo; }

}

}

D. public class FaxArgs : EventArgs

{

private string coverPageInfo; public string CoverPageInformation

{

get { return this.coverPageInfo; }

}

}

Correct Answer: A


QUESTION 12

You write the following code segment to call a function from the Win32 Application Programming Interface (API) by using platform invoke.

string personName = "N?el";

string msg = "Welcome" + personName + "to club"!";

bool rc = User32API.MessageBox(0, msg, personName, 0);

You need to define a method prototype that can best marshal the string data. Which code segment should you use?

A. [DllImport("user32", CharSet = CharSet.Ansi)]

public static extern bool MessageBox(int hWnd, String text, String caption, uint type); }

B. [DllImport("user32", EntryPoint = "MessageBoxA", CharSet = CharSet.Ansi)] public static extern bool MessageBox(int hWnd, [MarshalAs(UnmanagedType.

LPWStr)] String text, [MarshalAs(UnmanagedType.LPWStr)]String caption, uint type); }

C. [DllImport("user32", CharSet = CharSet.Unicode)]

public static extern bool MessageBox(int hWnd, String text, String caption, uint type); }

D. [DllImport("user32", EntryPoint = "MessageBoxA", CharSet = CharSet.Unicode)] public static extern bool MessageBox(int hWnd, [MarshalAs(UnmanagedType.

LPWStr)]String text, [MarshalAs(UnmanagedType.LPWStr)]String caption, uint type); }

Correct Answer: C


QUESTION 13

You are developing an application that receives events asynchronously. You create a WqlEventQuery instance to specify the events and event conditions to which the application must respond. You also create a ManagementEventWatcher instance to subscribe to events matching the query. You need to identify the other actions you must perform before the application can receive events asynchronously. Which two actions should you perform?

(Each correct answer presents part of the solution. Choose two.)

A. Start listening for events by calling the Start method of the ManagementEventWatcher.

B. Set up a listener for events by using the EventArrived event of the ManagementEventWatcher.

C. Use the WaitForNextEvent method of the ManagementEventWatcher to wait for the events.

D. Create an event handler class that has a method that receives an ObjectReadyEventArgs parameter.

E. Set up a listener for events by using the Stopped event of the ManagementEventWatcher.

Correct Answer: AB


QUESTION 14

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?

A. 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;

B. MemoryStream strm = new MemoryStream(document);

DeflateStream deflate = new DeflateStream(strm, CompressionMode.Comress); deflate.Write(document, 0, document.Length); deflate.Close();

return strm.ToArray();

C. MemoryStream strm = new MemoryStream();

DeflateStream deflate = new DeflateStream(strm, CompressionMode.Compress); deflate.Write(document, 0, document.Length); deflate.Close();

return strm.ToArray();

D. 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: C


QUESTION 15

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?

A. SoapFormatter formatter = new SoapFormatter(); byte[] buffer = new byte[dept.Capacity]; MemoryStream stream = new MemoryStream(buffer); foreach (object o in dept)

{

formatter.Serialize(stream, o);

}

B. SoapFormatter formatter = new SoapFormatter(); byte[] buffer = new byte[dept.Capacity]; MemoryStream stream = new MemoryStream(buffer); formatter.Serialize(stream, dept);

C. SoapFormatter formatter = new SoapFormatter(); MemoryStream stream = new MemoryStream(); foreach (object o in dept)

{

Formatter.Serialize(stream, o);

}

D. SoapFormatter formatter = new SoapFormatter(); MemoryStream stream = new MemoryStream(); formatter.Serialize(stream, dept);

Correct Answer: D


QUESTION 16

You need to create a class definition that is interoperable along with COM.

You need to ensure that COM applications can create instances of the class and can call the GetAddress method. Which code segment should you use?

A. public class Customer{ string addressString;

public Customer(string address)

{

addressString = address;

}

public string GetAddress()

{

return addressString;

}

}

B. public class Customer

{ static string addressString; public Customer() { }

public static string GetAddress()

{

return addressString;

}

}

C. public class Customer

{ string addressString; public Customer() { } public string GetAddress()

{

return addressString;

}

}

D. public class Customer

{ string addressString; public Customer() { } internal string GetAddress()

{

return addressString;

}

}

Correct Answer: C


QUESTION 17

You are developing a method to hash data with the Secure Hash Algorithm. The data is passed to your method as a byte array named message. You need to compute the hash of the incoming parameter by using SHA1. You also need to place the result into a byte array named hash. Which code segment should you use?

A. SHA1 sha = new SHA1CryptoServiceProvider(); byte[] hash = null;

sha.TransformBlock(message, 0, message.Length, hash, 0);

B. SHA1 sha = new SHA1CryptoServiceProvider();

byte[] hash = BitConverter.GetBytes(sha.GetHashCode());

C. SHA1 sha = new SHA1CryptoServiceProvider(); byte[] hash = sha.ComputeHash(message);

D. SHA1 sha = new SHA1CryptoServiceProvider(); sha.GetHashCode();

byte[] hash = sha.Hash;

Correct Answer: C


QUESTION 18

You are developing a method to hash data for later verification by using the MD5 algorithm. The data is passed to your method as a byte array named message. You need to compute the hash of the incoming parameter by using MD5. You also need to place the result into a byte array. Which code segment should you use?

A. HashAlgorithm algo = HashAlgorithm.Create("MD5"); byte[] hash = algo.ComputeHash(message);

B. HashAlgorithm algo = HashAlgorithm.Create("MD5"); byte[] hash = BitConverter.GetBytes(algo.GetHashCode());

C. HashAlgorithm algo;

algo = HashAlgorithm.Create(message.ToString()); byte[] hash = algo.Hash;

D. HashAlgorithm algo = HashAlgorithm.Create("MD5"); byte[] hash = null;

algo.TransformBlock(message, 0, message.Length, hash, 0);

Correct Answer: A


QUESTION 19

You need to create a dynamic assembly named MyAssembly. You also need to save the assembly to disk.

Which code segment should you use?

A. AssemblyName myAssemblyName = new AssemblyName();

AssemblyBuilder myAssemblyBuilder = AppDomain.CurrentDomain.DefineDynamicAssembly (myAssemblyName, AssemblyBuilderAccess.RunAndSave); myAssemblyBuilder.Save("MyAssembly.dll");

B. AssemblyName myAssemblyName = new AssemblyName();

myAssemblyName.Name = "MyAssembly";

AssemblyBuilder myAssemblyBuilder = AppDomain.CurrentDomain.DefineDynamicAssembly (myAssemblyName, AssemblyBuilderAccess.Save); myAssemblyBuilder.Save("MyAssembly.dll");

C. AssemblyName myAssemblyName = new AssemblyName("MyAssembly"); AssemblyBuilder myAssemblyBuilder = AppDomain.CurrentDomain.

DefineDynamicAssembly (myAssemblyName, AssemblyBuilderAccess.Save); myAssemblyBuilder.Save("c:\\MyAssembly.dll");

D. AssemblyName myAssemblyName = new AssemblyName(); myAssemblyName.Name = "MyAssembly";

AssemblyBuilder myAssemblyBuilder = AppDomain.CurrentDomain.DefineDynamicAssembly (myAssemblyName, AssemblyBuilderAccess.Run); myAssemblyBuilder.Save("MyAssembly.dll");

Correct Answer: B


QUESTION 20

You need to call an unmanaged function from your managed code by using platform invoke services. What should you do?

A. Create a class to hold DLL functions and then create prototype methods by using managed code.

B. Register your assembly by using COM and then reference your managed code from COM.

C. Export a type library for your managed code.

D. Import a type library as an assembly and then create instances of COM object.

Correct Answer: A

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