Chinese(T) | English
contact me
User Login
Username:
Password :

TS:MS.NET Framework 2.0-Application Develop Foundation

Index >> Microsoft >> MCTS >> "70-536"Exam

VUE/Prometric Code:70-536

Exam Name:TS:MS.NET Framework 2.0-Application Develop Foundation
Questions and Answers:264 Q&As
Price:$ 89
Updated:2008-12-01
TS:MS.NET Framework 2.0-Application Develop Foundation
Test Q&A Updated Price
70-536 264 Q&A 2008-12-01 $ 89

please download in PDF format Demo: 70-536

killtest 70-536 Exam Features

High quality and Value for the 70-536 Exam.
Killtest Practice Exams for TS:MS.NET Framework 2.0-Application Develop Foundation 70-536 are written to the highest standards of technical accuracy, using only certified subject matter experts and published authors for development.

100% Guarantee to Pass Your MCTS exam and get your MCTS Certification.
We guarantee your success in the first attempt. If you do not pass the 70-536 (TS:MS.NET Framework 2.0-Application Develop Foundation) on your first attempt we will give you a FULL REFUND of your purchasing fee AND send you another same value product for free.

killtest 70-536 Downloadable.
Printable Exams (in PDF format) Our Exam 70-536 Preparation Material provides you everything you will need to take your MCTS exam. The MCTS Certification details are researched and produced by Professional Certification Experts who are constantly using industry experience to produce precise, and logical. You may get MCTS exam questions from different web sites or books, but logic is the key. Our Product will help you not only pass in the first MCTS exam try, but also save your valuable time .

  • Comprehensive questions with complete details about 70-536 exam.
  • 70-536 exam questions accompanied by exhibits.
  • Verified Answers Researched by Industry Experts and almost 100% correct.
  • Drag and Drop questions as experienced in the Real MCTS exam.
  • 70-536 exam questions updated on regular basis.
  • Like actual MCTS Certification exams, 70-536 exam preparation is in multiple-choice questions (MCQs).
  • Tested by many real MCTS exams before publishing.
  • Try free MCTS exam demo before you decide to buy it in http://www.Killtest.com.

High quality and Value for the 70-536 Exam:100% Guarantee to Pass Your MCTS exam and get your MCTS Certification.

http://www.Killtest.com The safer.easier way to get MCTS Certification.

We offer Demo version of Q&A, Q&A are as follows (not to provide picture):

70-536:please download 70-536 in PDF format Demo 70-536

1.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;
Answer: A

2.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?
A. public class Age {     public int Value;    
public object CompareTo(object obj)
{       if (obj is Age)
{         Age _age = (Age) obj;        
return Value.CompareTo(obj);       }      
throw new ArgumentException("object not an Age");     }   }
B. public class Age {    
public int Value;    
public object CompareTo(int iValue) {      
try {        
return Value.CompareTo(iValue);       }
catch {        
throw new ArgumentException ("object not an Age");       }     }   }
C. public class Age : Icomparable {    
public int Value;    
public int CompareTo(object obj)
{       if (obj is Age) {        
Age _age = (Age) obj;        
return Value.CompareTo(_age.Value);       }      
throw new ArgumentException("object not an Age");     }   }
D. public class Age : Icomparable {    
public int Value;    
public int CompareTo(object obj) {      
try {        
return Value.CompareTo(((Age) obj).Value);       }
catch {        
return -1;       }     }   }
Answer: C

3.You are creating a class to compare a specially-formatted string. The default collation comparisons do not apply. You need to implement the Icomparable<string> interface.  Which code segment should you use?
A. public class Person : Icomparable<string>{   public int CompareTo(string other){      …   }}
B. public class Person : Icomparable<string>{   public int CompareTo(object other){      …   }}
C. public class Person : Icomparable<string>{   public bool CompareTo(string other){      …   }}
D. public class Person : Icomparable<string>{   public bool CompareTo(object other){      …   }}
Answer: A

4.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.
Answer: A

5.You are developing an application to assist the user in conducting electronic surveys. The survey consists of 25 true-or-false questions. You need to perform the following tasks: Initialize each answer to true.Minimize the amount of memory used by each survey. Which storage option should you choose?
A. BitVector32 answers = new BitVector32(1);
B. BitVector32 answers = new BitVector32(-1);
C. BitArray answers = new BitArray (1);
D. BitArray answers = new BitArray(-1);
Answer: B

6.You need to identify a type that meets the following criteriA. ?      
Is always a number.?      
Is not greater than 65,535.
Which type should you choose?
A. System.UInt16
B. int
C. System.String
D. System.IntPtr
Answer: A

7.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;}
Answer: B

8.You write a class named Employee that includes the following code segment.
public class Employee {string employeeId, employeeName, jobTitleName;   
public string GetName() { return employeeName; }   
public string GetTitle() { return jobTitleName; }
You need to expose this class to COM in a type library. The COM interface must also facilitate forward-compatibility across new versions of the Employee class. You need to choose a method for generating the COM interface.  What should you do?
A. Add the following attribute to the class definition.
 [ClassInterface(ClassInterfaceType.None)]public class Employee {}
B. Add the following attribute to the class definition.
 [ClassInterface(ClassInterfaceType.AutoDual)]public class Employee {}
C. Add the following attribute to the class definition.
 [ComVisible(true)]public class Employee {}
D. Define an interface for the class and add the following attribute to the class definition.
 [ClassInterface(ClassInterfaceType.None)]public class Employee : Iemployee {}
Answer: D

9.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.
Answer: A
10.You write the following code to call a function from the Win32 Application Programming Interface (API) by using platform invoke. 

You need to define a method prototype. Which code segment should you use?
A. [DllImport("user32")]public static extern int MessageBox(int hWnd, String text, String caption, uint type);
B. [DllImport("user32")]
 public static extern int MessageBoxA(int hWnd,String text, String caption, uint type);
C. [DllImport("user32")]
 public static extern int Win32API_User32_MessageBox(int hWnd, String text, String caption, uint type);
D. [DllImport(@"C. \WINDOWS\system32\user32.dll")]
 public static extern int MessageBox(int hWnd, String text, String caption, uint type);
Answer: A

11.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";message.Dispose();
B. 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);
C. 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);
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";
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);
Answer: C

12.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();
myAssemblyName.Name = "MyAssembly";
AssemblyBuilder myAssemblyBuilder =AppDomain.CurrentDomain.DefineDynamicAssembly   
(myAssemblyName, AssemblyBuilderAccess.Run);
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();
AssemblyBuilder myAssemblyBuilder = AppDomain.CurrentDomain.DefineDynamicAssembly   
(myAssemblyName, AssemblyBuilderAccess.RunAndSave);
myAssemblyBuilder.Save("MyAssembly.dll");
D. AssemblyName myAssemblyName =new AssemblyName("MyAssembly");
AssemblyBuilder myAssemblyBuilder =AppDomain.CurrentDomain.DefineDynamicAssembly   
(myAssemblyName, AssemblyBuilderAccess.Save);
myAssemblyBuilder.Save("C. \\MyAssembly.dll");
Answer: B

13.You need to write a code segment that performs the following tasks: ?      
Retrieves the name of each paused service. ?
Passes the name to the Add method of Collection1.
Which code segment should you use?
A. ManagementObjectSearcher searcher =  new ManagementObjectSearcher("Select * from Win32_Service
 where State = 'Paused'");
 foreach (ManagementObject svc in searcher.Get()) {Collection1.Add(svc["DisplayName"]); }
B. ManagementObjectSearcher searcher = new ManagementObjectSearcher("Select * from Win32_Service",
 "State = 'Paused'");
 foreach (ManagementObject svc in searcher.Get()) {  Collection1.Add(svc["DisplayName"]);}
C. ManagementObjectSearcher searcher =  new ManagementObjectSearcher(  "Select * from Win32_Service");
 foreach (ManagementObject svc in searcher.Get())
 {if ((string) svc["State"] == "'Paused'") {Collection1.Add(svc["DisplayName"]);  }}
D. ManagementObjectSearcher searcher =new ManagementObjectSearcher();
 searcher.Scope = new ManagementScope("Win32_Service");
 foreach (ManagementObject svc in searcher.Get())
 {if ((string)svc["State"] == "Paused") {Collection1.Add(svc["DisplayName"]);  }}
Answer: A

14.Your company uses an application named Application1 that was compiled by using the .NET Framework version 1.0. The application currently runs on a shared computer on which the .NET Framework versions 1.0 and 1.1 are installed.  You need to move the application to a new computer on which the .NET Framework versions 1.1 and 2.0 are installed. The application is compatible with the .NET Framework 1.1, but it is incompatible with the .NET Framework 2.0. You need to ensure that the application will use the .NET Framework version 1.1 on the new computer. What should you do?
A. Add the following XML element to the application configuration file.  
<configuration>   
<startup>     
<supportedRuntime version="1.1.4322" />   
<startup> 
</configuration>
B. Add the following XML element to the application configuration file.  
<configuration>   
<runtime>     
<assemblyBinding  xmlns="urn:schemas-microsoft-com:asm.v1">        
<dependentAssembly>           
<assemblyIdentity name="Application1"
publicKeyToken="32ab4ba45e0a69a1"  culture="neutral" />           
<bindingRedirect oldVersion="1.0.3075.0" newVersion="1.1.4322.0"/>        
</dependentAssembly>     
</assemblyBinding>  
</runtime> 
</configuration>
C. Add the following XML element to the machine configuration file.  
<configuration>   
<startup>     
<requiredRuntime version="1.1.4322" />   
<startup> 
</configuration>
D. Add the following XML element to the machine configuration file.  
<configuration>   
<runtime>     
<assemblyBinding  xmlns="urn:schemas-microsoft-com:asm.v1">  
<dependentAssembly>           
<assemblyIdentity name="Application1"
publicKeyToken="32ab4ba45e0a69a1"  culture="neutral" />           
<bindingRedirect oldVersion="1.0.3075.0" newVersion="1.1.4322.0"/>        
</dependentAssembly>     
</assemblyBinding>  
</runtime> 
</configuration>
Answer: A

15.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 "John" You also need to ensure that the code segment simultaneously facilitates uninterrupted execution of the application. Which code segment should you use?
A. Debug.Assert(fName == "John", "Test FaileD. ", fName);
B. Debug.WriteLineIf(fName != "John", fName, "Test Failed");
C. if (fName != "John") {Debug.Print("Test FaileD. "); Debug.Print(fName);   }
D. if (fName != "John") {Debug.WriteLine("Test FaileD. "); Debug.WriteLine(fName);   }
Answer: B

16.You are creating an application that lists processes on remote computers. The application requires a method that performs the following tasks: Accept the remote computer name as a string parameter named strComputer.Return an ArrayList object that contains the names of all processes that are running on that computer. You need to write a code segment that retrieves the name of each process that is running on the remote computer and adds the name to the ArrayList object. Which code segment should you use?
A. ArrayList al = new ArrayList();
Process[] procs = Process.GetProcessesByName(strComputer);
foreach (Process proc in procs) {  al.Add(proc);}
B. ArrayList al = new ArrayList();
Process[] procs = Process.GetProcesses(strComputer);
foreach (Process proc in procs) {  al.Add(proc);}
C. ArrayList al = new ArrayList();
Process[] procs = Process.GetProcessesByName(strComputer);
foreach (Process proc in procs) {al.Add(proc.ProcessName);}
D. ArrayList al = new ArrayList();
Process[] procs = Process.GetProcesses(strComputer);
foreach (Process proc in procs) {al.Add(proc.ProcessName);}
Answer: D

17.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); }
Answer: C

18.You are creating an application that retrieves values from a custom section of the application configuration file. The custom section uses XML as shown in the following block.   

You need to write a code segment to define a class named Role. You need to ensure that the Role class is initialized with values that are retrieved from the custom section of the configuration file. Which code segment should you use?
A. public class Role :
ConfigurationElement {    
internal string _ElementName = "name";    
[ConfigurationProperty("role")]    
public string Name {      
get {         
return ((string)base["role"]);        }     }   }
B. public class Role :
ConfigurationElement {    
internal string _ElementName = "role";    
[ConfigurationProperty("name", RequiredValue = true)]    
public string Name {      
get {         
return ((string)base["name"]);        }     }   }
C. public class Role :
ConfigurationElement {    
internal string _ElementName = "role";    
private string _name;    
[ConfigurationProperty("name")]    
public string Name {      
get {         
return _name;        }     }   }
D. public class Role :
ConfigurationElement {    
internal string _ElementName = "name";    
private string _name;    
[ConfigurationProperty("role", RequiredValue = true)]    
public string Name {      
get {         
return _name;        }     }   }
Answer: B

19.You need to generate a report that lists language codes and region codes.  Which code segment should you use?
A. foreach (CultureInfo culture in CultureInfo.GetCultures(CultureTypes.SpecificCultures))
 {      // Output the culture information…}
B. CultureInfo culture = new CultureInfo(""); CultureTypes types = culture.CultureTypes;    
  // Output the culture information…
C. foreach (CultureInfo culture in CultureInfo.GetCultures(CultureTypes.NeutralCultures))
 {      // Output the culture information…}
D. foreach (CultureInfo culture in CultureInfo.GetCultures(CultureTypes.ReplacementCultures))
 {      // Output the culture information…}
Answer: A

20.You create an application that stores information about your customers who reside in various regions. You are developing internal utilities for this application.  You need to gather regional information about your customers in Canada.  Which code segment should you use?
A. foreach (CultureInfo culture in CultureInfo.GetCultures(CultureTypes.SpecificCultures))
 { // Output the region information…}
B. CultureInfo cultureInfo = new CultureInfo("CA"); // Output the region information…
C. RegionInfo regionInfo = new RegionInfo("CA"); // Output the region information…
D. RegionInfo regionInfo = new RegionInfo("");if (regionInfo.Name == "CA")
 {  // Output the region information…}
Answer: C

21.You are developing a method that searches a string for a substring. The method will be localized to Italy.  Your method accepts the following parameters: The string to be searched, which is named searchListThe string for which to search, which is named searchValue You need to write the code. Which code segment should you use?
A. return searchList.IndexOf(searchValue);
B. CompareInfo comparer = new CultureInfo("it-IT").CompareInfo;
 return comparer.Compare(searchList, searchValue);
C. CultureInfo comparer = new CultureInfo("it-IT");
 if (searchList.IndexOf(searchValue) > 0) {return true;}
 else {return false;}
D. CompareInfo comparer = new CultureInfo("it-IT").CompareInfo;
 if (comparer.IndexOf(searchList, searchValue) > 0) {return true;}
 else { return false;}
Answer: D

22.You are developing an application for a client residing in Hong Kong. 
You need to display negative currency values by using a minus sign. Which code segment should you use?
A. NumberFormatInfo culture = new CultureInfo("zh-HK").NumberFormat;
 culture.NumberNegativePattern = 1; return numberToPrint.ToString("C", culture);
B. NumberFormatInfo culture = new CultureInfo("zh-HK").NumberFormat;
 culture.CurrencyNegativePattern = 1; return numberToPrint.ToString("C", culture);
C. CultureInfo culture =new CultureInfo("zh-HK"); return numberToPrint.ToString("-(0)", culture);
D. CultureInfo culture =new CultureInfo("zh-HK"); return numberToPrint.ToString("()", culture);
Answer: B

23.You are developing a fiscal report for a customer. Your customer has a main office in the United States and a satellite office in Mexico.  You need to ensure that when users in the satellite office generate the report, the current date is displayed in Mexican Spanish format. Which code segment should you use?
A. DateTimeFormatInfo dtfi = new CultureInfo("es-MX", false).DateTimeFormat;
DateTime dt = new DateTime(DateTime.Today.Year, DateTime.Today.Month, DateTime.Today.Day);
string dateString = dt.ToString(dtfi.LongDatePattern);
B. Calendar cal = new CultureInfo("es-MX", false).Calendar;
DateTime dt = new DateTime(DateTime.Today.Year, DateTime.Today.Month, DateTime.Today.Day);
Strong dateString = dt.ToString();
C. string dateString = DateTimeFormatInfo.CurrentInfo GetMonthName(DateTime.Today.Month);
D. string dateString = DateTime.Today.Month.ToString("es-MX");
Answer: A

24.You are developing a method to encrypt sensitive data with the Data Encryption Standard (DES) algorithm. Your method accepts the following parameters:  The byte array to be encrypted, which is named messageAn encryption key, which is named keyAn initialization vector, which is named iv  You need to encrypt the data. You also need to write the encrypted data to a MemoryStream object.  Which code segment should you use?
A. DES des = new DESCryptoServiceProvider();
des.BlockSize = message.Length;
ICryptoTransform crypto = des.CreateEncryptor(key, iv);
MemoryStream cipherStream = new MemoryStream();
CryptoStream cryptoStream = new CryptoStream(cipherStream,   crypto, CryptoStreamMode.Write); cryptoStream.Write(message, 0, message.Length);
B. DES des = new DESCryptoServiceProvider();
ICryptoTransform crypto = des.CreateDecryptor(key, iv);
MemoryStream cipherStream = new MemoryStream();
CryptoStream cryptoStream = new CryptoStream(cipherStream,  crypto, CryptoStreamMode.Write);
cryptoStream.Write(message, 0, message.Length);
C. DES des = new DESCryptoServiceProvider();
ICryptoTransform crypto = des.CreateEncryptor();
MemoryStream cipherStream = new MemoryStream();
CryptoStream cryptoStream = new CryptoStream(cipherStream,  crypto, CryptoStreamMode.Write);
cryptoStream.Write(message, 0, message.Length);
D. DES des = new DESCryptoServiceProvider();
ICryptoTransform crypto = des.CreateEncryptor(key, iv);
MemoryStream cipherStream = new MemoryStream();
CryptoStream cryptoStream = new CryptoStream(cipherStream,   crypto, CryptoStreamMode.Write);
cryptoStream.Write(message, 0, message.Length);
Answer: D

25.You are developing a method to call a COM component. You need to use declarative security to explicitly request the runtime to perform a full stack walk. You must ensure that all callers have the required level of trust for COM interop before the callers execute your method. Which attribute should you place on the method?
A. [SecurityPermission(SecurityAction.Demand, Flags=SecurityPermissionFlag.UnmanagedCode)]
B. [SecurityPermission(SecurityAction.LinkDemand, 
   Flags=SecurityPermissionFlag.UnmanagedCode)]
C. [SecurityPermission(SecurityAction.Assert, Flags = SecurityPermissionFlag.UnmanagedCode)]
D. [SecurityPermission(SecurityAction.Deny, Flags = SecurityPermissionFlag.UnmanagedCode)]
Answer: A

26.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);
Answer: A

27.ou create a method that runs by using the credentials of the end user. You need to use Microsoft Windows groups to authorize the user. You must add a code segment that identifies whether a user is in the local group named Clerk.  Which code segment should you use?
A. WindowsIdentity currentUser = WindowsIdentity.GetCurrent();
foreach (IdentityReference grp in currentUser.Groups)
{NTAccount grpAccount = ((NTAccount)grp.Translate(typeof(NTAccount)));   
isAuthorized = grpAccount.Value.Equals(Environment.MachineName + @"\Clerk");   
if (isAuthorized) break;}
B. WindowsPrincipal currentUser = (WindowsPrincipal)Thread.CurrentPrincipal;
 isAuthorized = currentUser.IsInRole("Clerk");
C. GenericPrincipal currentUser = (GenericPrincipal) Thread.CurrentPrincipal;
 isAuthorized = currentUser.IsInRole("Clerk");
D. WindowsPrincipal currentUser = (WindowsPrincipal)Thread.CurrentPrincipal;
 isAuthorized = currentUser.IsInRole(Environment.MachineName);
Answer: B

28.You are changing the security settings of a file named MyData.xml.  You need to preserve the existing inherited access rules. You also need to prevent the access rules from inheriting changes in the future.  Which code segment should you use?
A. FileSecurity security = new FileSecurity("mydata.xml", AccessControlSections.All);
 security.SetAccessRuleProtection(true, true);File.SetAccessControl("mydata.xml", security);
B. FileSecurity security = new FileSecurity();
 security.SetAccessRuleProtection(true, true);File.SetAccessControl("mydata.xml", security);
C. FileSecurity security = File.GetAccessControl("mydata.xml");security.SetAccessRuleProtection(true, true);
D. FileSecurity security = File.GetAccessControl("mydata.xml");
 security.SetAuditRuleProtection(true, true);File.SetAccessControl("mydata.xml", security);
Answer: A

29.You are writing code for user authentication and authorization. The username, password, and roles are stored in your application data store.  You need to establish a user security context that will be used for authorization checks such as IsInRole. You write the following code segment to authorize the user. 

You need to complete this code so that it establishes the user security context. Which code segment should you use?
A. GenericIdentity ident = new GenericIdentity(userName);
GenericPrincipal currentUser =     new GenericPrincipal(ident, userRolesArray);
Thread.CurrentPrincipal = currentUser;
B. WindowsIdentity ident = new WindowsIdentity(userName);
WindowsPrincipal currentUser = new WindowsPrincipal(ident);
Thread.CurrentPrincipal = currentUser;
C. NTAccount userNTName = new NTAccount(userName);
GenericIdentity ident = new GenericIdentity(userNTName.Value);
GenericPrincipal currentUser= new GenericPrincipal(ident, userRolesArray);
Thread.CurrentPrincipal = currentUser;
D. IntPtr token = IntPtr.Zero;token = LogonUserUsingInterop(userName, encryptedPassword);
 WindowsImpersonationContext ctx =    WindowsIdentity.Impersonate(token);
Answer: A

30.You are loading a new assembly into an application. You need to override the default evidence for the assembly. You require the common language runtime (CLR) to grant the assembly a permission set, as if the assembly were loaded from the local intranet zone. You need to build the evidence collection. Which code segment should you use?
A. Evidence evidence = new Evidence(Assembly.GetExecutingAssembly().Evidence  );
B. Evidence evidence = new Evidence();evidence.AddAssembly(new Zone(SecurityZone.Intranet));
C. Evidence evidence = new Evidence();evidence.AddHost(new Zone(SecurityZone.Intranet));
D. Evidence evidence = new Evidence(AppDomain.CurrentDomain.Evidence  );
Answer: C