Ensurepass

 

QUESTION 1

You are developing a custom event handler to automatically print all open documents. The event handler helps specify the number of copies to be printed. You need to develop a custom event arguments class to pass as a parameter to the event handler.

Which code segment should you use?

A. public class PrintingArgs

{

private int copies;

public PrintingArgs(int numberOfCopies)

{

this.copies = numberOfCopies;

}

public int Copies

{

get { return this.copies; }

}

}

B. public class PrintingArgs : EventArgs

{

private int copies;

public PrintingArgs(int numberOfCopies)

{

this.copies = numberOfCopies;

}

public int Copies

{

get { return this.copies; }

}

}

C. public class PrintingArgs

{

private EventArgs eventArgs; public PrintingArgs(EventArgs ea)

{

this.eventArgs = ea;

}

public EventArgs Args

{

get { return eventArgs; }

}

}

D. public class PrintingArgs : EventArgs

{

private int copies;

}

Correct Answer: B


QUESTION 2

You use Reflection to obtain information about a method named MyMethod. You need to ascertain whether MyMethod is accessible to a derived class. What should you do?

A. Call the IsAssembly property of the MethodInfo class.

B. Call the IsVirtual property of the MethodInfo class.

C. Call the IsStatic property of the MethodInfo class.

D. Call the IsFamily property of the MethodInfo class.

Correct Answer: D


QUESTION 3

You are creating a class that uses unmanaged resources. This class maintains references to managed resources on other objects. You need to ensure that users of this class can explicitly release resources when the class instance ceases to be needed. Which three actions should you perform? (Each correct answer presents part of the solution. Choose three.)

A. Define the class such that it inherits from the WeakReference class.

B. Define the class such that it implements the IDisposable interface.

C. Create a class destructor that calls methods on other objects to release the managed resources.

D. Create a class destructor that releases the unmanaged resources.

E. Create a Dispose method that calls System.GC.Collect to force garbage collection.

F. Create a Dispose method that releases unmanaged resources and calls methods on other objects to release the managed resources.

Correct Answer: BDF


QUESTION 4

You are working on a debug build of an application. You need to find the line of code that caused an exception to be thrown. Which property of the Exception class should you use to achieve this goal?

A. Data

B. Message

C. StackTrace

D. Source

Correct Answer: C


QUESTION 5

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?

A. EventLog myLog = new EventLog("Application", "."); foreach (EventLogEntry entry in myLog.Entries)

{

if (entry.Source == "MySource")

{

PersistToDB(entry);

}

}

B. EventLog myLog = new EventLog("Application", "."); myLog.Source = "MySource";

foreach (EventLogEntry entry in myLog.Entries)

{

if (entry.EntryType == (EventLogEntryType.Error & EventLogEntryType.Warning)) { PersistToDB(entry);

}

}

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

}

}

}

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


QUESTION 6

Your application uses two threads, named threadOne and threadTwo. You need to modify the code to prevent the execution of thread One until thread Two completes execution.

What should you do?

A. Configure threadOne to run at a lower priority.

B. Configure threadTwo to run at a higher priority.

C. Use a WaitCallback delegate to synchronize the threads.

D. Call the Sleep method of threadOne.

E. Call the SpinLock method of threadOne.

Correct Answer: C


QUESTION 7

You are writing a custom dictionary. The custom-dictionary class is named MyDictionary. You need to ensure that the dictionary is type safe. Which code segment should you use?

A. class MyDictionary : Dictionary<string, string>

B. class MyDictionary : HashTable

C. class MyDictionary : IDictionary

D. class MyDictionary { … }

Dictionary<string, string> t = new Dictionary<string, string>(); MyDictionary dictionary = (MyDictionary)t;

Correct Answer: A


QUESTION 8

You are creating an assembly named Assembly1. Assembly1 contains a public method. The global cache contains a second assembly named Assembly2. You must ensure that the public method is only called from Assembly2. Which permission class should you use?

A. GacIdentityPermission

B. StrongNameIdentityPermission

C. DataProtectionPermission

D. PublisherIdentityPermission

Correct Answer: B


QUESTION 9

You create an application to send a message by e-mail. An SMTP server is available on the local subnet. The SMTP server is named smtp.contoso.com.

To test the application, you use a source address, me@contoso.com, and a target address, you@contoso.com. You need to transmit the e-mail message.

Which code segment should you use?

A. MailAddress addrFrom = new MailAddress("me@contoso.com", "Me"); MailAddress addrTo = new MailAddress("you@contoso.com", "You"); MailMessage message = new MailMessage(addrFrom, addrTo); message.Subject = "Greetings!"; message.Body = "Test";

SocketInformation info = new SocketInformation(); Socket client = new Socket(info);

System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding(); byte[] msgBytes = enc.GetBytes(message.ToString()); client.Send(msgBytes);

B. MailAddress addrFrom = new MailAddress("me@contoso.com"); MailAddress addrTo = new MailAddress("you@contoso.com"); MailMessage message = new MailMessage(addrFrom, addrTo); message.Subject = "Greetings!";

message.Body = "Test";

SmtpClient client = new SmtpClient("smtp.contoso.com"); client.Send(message);

C. string strSmtpClient = "smtp.contoso.com"; string strFrom = "me@contoso.com"; string strTo = "you@contoso.com";

string strSubject = "Greetings!"; string strBody = "Test";

MailMessage msg = new MailMessage(strFrom, strTo, strSubject, strSmtpClient);

D. MailAddress addrFrom = new MailAddress("me@contoso.com", "Me"); MailAddress addrTo = new MailAddress("you@contoso.com", "You"); MailMessage message = new MailMessage(addrFrom, addrTo); message.Subject = "Greetings!";

message.Body = "Test"; message.Dispose();

Correct Answer: B


QUESTION 10

You are developing a custom-collection class. You need to create a method in your class. You need to ensure that the method you create in your class returns a type that is compatible with the Foreach statement. Which criterion should the method meet?

A. The method must return a type of either IEnumerator or IEnumerable.

B. The method must return a type of IComparable.

C. The method must explicitly contain a collection.

D. The method must be the only iterator in the class.

Correct Answer: A

 

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

Comments are closed.