You are on page 1of 51

TS: Microsoft .

NET Framework, Application Development Foundation


Question Number (ID) : 1 (536P_1.3_05)

______________________________________________________________________________________________________________ Which of the following types CANNOT be marshaled between managed and unmanaged processes?

1. Arrays 2. Generic types 3. Strings 4. Structures 5. Boolean types 6. Delegates <Correct>

Explanation: Generic types cannot be marshaled between managed and unmanaged memory. Arrays, boolean types, char types, delegates, classes, objects, strings, and structures can be marshaled.

Objective: Developing applications that use system types and collections Sub Objective(s): Improve type safety and application performance in a .NET Framework application by using generic collections. References: MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework - Application Development Foundation, Second Edition Chapter 13 - Lessons 1 and 2 Default Marshaling Behavior MSDN Library Link: http://msdn.microsoft.com/library/zah6xy75.aspx

TS: Microsoft .NET Framework, Application Development Foundation


Question Number (ID) : 2 (536P_2.1_03)

______________________________________________________________________________________________________________ What is the preferred way for a service to interact with a user?

1. By opening a Web browser 2. By opening a dialog box 3. By writing a message to a text file 4. By writing an event to the event log <Correct>

Explanation: Services do not have a user interface. Therefore, they cannot directly interact with the user by opening a dialog box or Web browser. Instead, you should write events to the event log. Although you could write messages to a text file, the event log is easier to manage, especially in enterprise environments.

Objective: Implementing service processes, threading, and application domains in a .NET Framework application Sub Objective(s): Implement, install, and control a service. References: MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework - Application Development Foundation, Second Edition Chapter 8 - Lesson 3 ServiceController Class MSDN Library Link: http://msdn.microsoft.com/library/system.serviceprocess.servicecontroller.aspx Introduction to Windows Service Applications MSDN Library Link: http://msdn.microsoft.com/library/d56de412.aspx

TS: Microsoft .NET Framework, Application Development Foundation


Question Number (ID) : 3 (536P_3.2_07)

______________________________________________________________________________________________________________ You have derived a custom class from the Installer class. If the user cancels an installation, you need to run special code to remove changes you have made. Which of the following Installer methods would you place the code in?

1. Install 2. OnCommitting 3. Rollback 4. OnRollback 5. Commit <Correct>

Explanation: Use the Rollback method to remove changes made during installation when the install is cancelled. The Install method performs the actual installation. The Commit method finalizes installation changes. The OnCommitting method runs immediately before the Commit method. There is no OnRollback method.

Objective: Embedding configuration, diagnostic, management, and installation features into a .NET Framework application Sub Objective(s): Create a custom Microsoft Windows Installer for .NET components by using the System.Configuration.Install namespace, and configure .NET Framework applications by using configuration files, environment variables, and the .NET Framework Configuration tool (Mscorcfg.msc). References: MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework - Application Development Foundation, Second Edition Chapter 9 - Lesson 2 Installer Class MSDN Library Link: http://msdn.microsoft.com/library/system.configuration.install.installer.aspx

TS: Microsoft .NET Framework, Application Development Foundation


Question Number (ID) : 4 (536P_4.2_04)

______________________________________________________________________________________________________________ Given the following C# class, which of the following files represents how an instance of that class would be serialized using the XmlSerializer class? public class ShoppingCartItem { public Int32 productId; public decimal price; public Int32 quantity; public decimal total; public ShoppingCartItem() { } }

1. <?xml version="1.0" ?> <productId>100</productId> <price>10.25</price> <quantity>2</quantity> <total>20.50</total> 2. <?xml version="1.0" ?> <ShoppingCartItem productId="100" price="10.25" quantity="2" total="20.50"> </ShoppingCartItem>

3. <?xml version="1.0" ?> <ShoppingCartItem> <productId>100</productId> <price>10.25</price> <quantity>2</quantity> <total>20.50</total> </ShoppingCartItem> <Correct> 4. <?xml version="1.0" ?> <ShoppingCartItem> <productId>100</productId> <price>10.25</price> <quantity>2</quantity> </ShoppingCartItem>

Explanation: By default, XmlSerializer serializes all members as Extensible Markup Language (XML) elements. XmlSerializer serializes members as attributes only if each member has the XmlAttribute attribute. XmlSerializer would ignore the total member only if it had the XmlIgnore attribute. XmlSerializer creates an element for the class and makes each member a subelement within the class element.

Objective: Implementing serialization and input/output functionality in a .NET Framework application Sub Objective(s): Control the serialization of an object into XML format by using the System.Xml.Serialization namespace. References:

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework - Application Development Foundation, Second Edition Chapter 5 - Lesson 2 Basic Serialization MSDN Library Link: http://msdn.microsoft.com/library/4abbf6k0.aspx XmlSerializer Class MSDN Library Link: http://msdn.microsoft.com/library/system.xml.serialization.xmlserializer.aspx Introducing XML Serialization MSDN Library Link: http://msdn.microsoft.com/library/182eeyhh.aspx

TS: Microsoft .NET Framework, Application Development Foundation


Question Number (ID) : 5 (536P_5.4_03)

______________________________________________________________________________________________________________ You are writing an assembly that verifies that files have not been modified since they were initially scanned. The checksums will be stored in a text file. Which hashing algorithms could you use to prevent an attacker from modifying both the file and the checksum? (Choose all that apply.)

1. SHA256 2. HMACSHA1 3. MD5 4. MACTripleDES <Correct> <Correct>

Explanation: HMACSHA1 and MACTripleDES are keyed hashing algorithms, which protect against modification of the hash by encrypting it through the use of a secret key that both the sender and receiver must have. MD5 and SHA256 are unkeyed hashing algorithms, which can be modified by an unauthorized user without being detected easily.

Objective: Improving the security of .NET Framework applications by using the .NET Framework security features Sub Objective(s): Encrypt, decrypt, and hash data by using the System.Security.Cryptography classes. References: MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework - Application Development Foundation, Second Edition Chapter 12 - Lesson 3 Cryptography Overview MSDN Library Link: http://msdn.microsoft.com/library/92f9ye3s.aspx KeyedHashAlgorithm Class MSDN Library Link: http://msdn.microsoft.com/library/system.security.cryptography.keyedhashalgorithm.aspx

TS: Microsoft .NET Framework, Application Development Foundation


Question Number (ID) : 6 (536P_6.3_03)

______________________________________________________________________________________________________________ You have created a Type object. Which method would you call to retrieve a collection containing all methods, interfaces, properties, and constructors for the class?

1. Type.GetFields 2. Type.GetDefaultMembers 3. Type.GetMethods 4. Type.GetMembers <Correct>

Explanation: Type.GetMembers retrieves all members, including methods, interfaces, properties, and constructors. Type.GetFields searches for fields defined by the current type. Type.GetDefaultMembers searches for members defined by the current type whose System.Reflection.DefaultMemberAttribute is set. Type.GetMethods returns a collection containing only methods, and not interfaces or properties.

Objective: Implementing interoperability, reflection, and mailing functionality in a .NET Framework application Sub Objective(s): Implement reflection functionality in a .NET Framework application, and create metadata, Microsoft intermediate language (MSIL), and a PE file by using the System.Reflection.Emit namespace. References: MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework - Application Development Foundation, Second Edition Chapter 14 - Lesson 1 Viewing Type Information MSDN Library Link: http://msdn.microsoft.com/library/t0cs7xez.aspx

TS: Microsoft .NET Framework, Application Development Foundation


Question Number (ID) : 7 (536P_7.1_05)

______________________________________________________________________________________________________________ Which of the following C# code samples correctly performs a culture-insensitive string comparison?

1. string s1 = "Apple"; string s2 = "ble"; int r = String.Compare(s1, s2, false, CultureInfo.InvariantCulture); <Correct> 2. string s1 = "Apple"; string s2 = "ble"; int r = String.Compare(s1, s2, false, CultureInfo.CurrentUICulture);

3. string s1 = "Apple"; string s2 = "ble"; int r = String.Compare(s1, s2, false, CultureInfo.CreateSpecificCulture("da-DK"));

4. string s1 = "Apple"; string s2 = "ble"; int r = String.Compare(s1, s2, false);

Explanation: By default, string comparisons are culture sensitive. To perform culture-insensitive comparisons, pass the CultureInfo.InvariantCulture parameter.

Objective: Implementing globalization, drawing, and text manipulation functionality in a .NET Framework application Sub Objective(s): Format data based on culture information. References: MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework - Application Development Foundation, Second Edition Chapter 16 - Lesson 1 How to: Use Finally Blocks MSDN Library Link: http://msdn.microsoft.com/library/ke0zf0f5.aspx

TS: Microsoft .NET Framework, Application Development Foundation


Question Number (ID) : 8 (536P_1.2_03)

______________________________________________________________________________________________________________ You are creating a new collection type that must be iterated using a foreach loop. Which of the following interfaces should you implement? (Choose all that apply.)

1. ICollection 2. IEqualityComparer 3. IDictionaryEnumerator 4. IDictionary 5. IEnumerable <Correct> <Correct>

Explanation: You must implement IEnumerable or IDictionaryEnumerator when creating a collection for use in a foreach loop. The ICollection interface is the base interface for classes in the System.Collections namespace. It does not support foreach loops. The IDictionary interface is the base interface for nongeneric collections of key/value pairs. It does not support foreach loops. The IEqualityComparer interface supports only equality comparisons and cannot be used in foreach loops.

Objective: Developing applications that use system types and collections Sub Objective(s): Manage a group of associated data in a .NET Framework application by using collections. References: MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework - Application Development Foundation, Second Edition Chapter 4 - Lesson 1 IEnumerable Interface MSDN Library Link: http://msdn.microsoft.com/en-us/library/system.collections.ienumerable.aspx IDictionaryEnumerator Interface MSDN Library Link: http://msdn.microsoft.com/en-us/library/system.collections.idictionaryenumerator.aspx

TS: Microsoft .NET Framework, Application Development Foundation


Question Number (ID) : 9 (536P_2.2_09)

______________________________________________________________________________________________________________ You are writing a multi-threaded application, and multiple threads need to read and write the same file. At times, a thread will need to read from the file and then immediately write to the file. What is the most efficient way to handle this in the thread?

1. 1. Create a ReaderWriterLock object and call ReaderWriterLock.AcquireWriteLock. 2. Perform both the reads and the writes.

2. 1. Create a ReaderWriterLock object and call ReaderWriterLock.AcquireReadLock. 2. Perform the reads. 3. Call ReaderWriterLock.UpgradeToWriterLock and perform the writes. <Correct> 3. 1. Create a ReaderWriterLock object and call ReaderWriterLock.AcquireReadLock. 2. Perform the reads. 3. Call ReaderWriterLock.ReleaseLock. 4. Call ReaderWriterLock.AcquireWriteLock and perform the writes.

4. 1. Create a ReaderWriterLock object and call ReaderWriterLock.AcquireReadLock. 2. Perform the reads. 3. Call ReaderWriterLock.ReleaseReaderLock. 4. Call ReaderWriterLock.AcquireWriteLock and perform the writes.

Explanation: The most efficient way to switch from a read lock to a write lock is to call ReaderWriterLock.UpgradeToWriterLock. You cannot read when you have a write lock. Although you can release a read lock and acquire a write lock, it is not as efficient as using UpgradeToWriterLock.

Objective: Implementing service processes, threading, and application domains in a .NET Framework application Sub Objective(s): Develop multithreaded .NET applications. References: MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework - Application Development Foundation, Second Edition Chapter 7 - Lesson 1 ReaderWriterLock Class MSDN Library Link: http://msdn.microsoft.com/library/system.threading.readerwriterlock.aspx

TS: Microsoft .NET Framework, Application Development Foundation


Question Number (ID) : 10 (536P_3.4_04)

______________________________________________________________________________________________________________ You are writing an application that requires the user to open a second application named Application.exe, make a configuration change, and then close the second application. You want to start the application automatically for the user and then wait indefinitely until the user closes the application. Which of the following C# code samples accomplishes this?

1. Process p = new Process(); p.StartInfo.FileName = "Application.exe"; p.Start(); p.WaitForExit(10000);

2. Process p = new Process("Application.exe"); p.Start(); p.WaitForExit();

3. Process p = new Process("Application.exe"); p.Start(); p.WaitForExit(10000);

4. Process p = new Process(); p.StartInfo.FileName = "Application.exe"; p.Start(); p.WaitForExit(); <Correct>

Explanation: To start a new process, first create an instance of the Process class, and then specify the Process.StartInfo.FileName property. Finally, call the Process.Start method. To stop processing until the application closes, call the Process.WaitForExit method without specifying a time. You cannot specify an application filename in the Process constructor. Specifying a time for the Process.WaitForExit method causes the runtime to continue execution after the specified time even if the application hasn't closed. You cannot specify an application filename in the Process constructor. In addition, specifying a time for the Process.WaitForExit method causes the runtime to continue execution after the specified time even if the application has not closed.

Objective: Embedding configuration, diagnostic, management, and installation features into a .NET Framework application Sub Objective(s): Manage system processes and monitor the performance of a .NET application by using the diagnostics functionality of the .NET Framework 2.0. References: MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework - Application Development Foundation, Second Edition Chapter 10 - Lesson 3 Process Class MSDN Library Link: http://msdn.microsoft.com/library/system.diagnostics.process.aspx

TS: Microsoft .NET Framework, Application Development Foundation


Question Number (ID) : 11 (536P_4.2_01)

______________________________________________________________________________________________________________ You are responsible for an internal database application. Your organization would now like to send information selectively from the database to external customers using Extensible Markup Language (XML) documents. Currently, you have custom classes that store this information. Which class is the best one to use to write the XML documents?

1. StreamWriter 2. XmlSerializer 3. TextWriter 4. BinaryFormatter <Correct>

Explanation: XmlSerializer is the most efficient way to write an object to an XML document. BinaryFormatter would write the object to disk, but it would not use XML. TextWriter and StreamWriter could be used to create XML documents, but it would be very inefficient because you would have to create the XML formatting manually.

Objective: Implementing serialization and input/output functionality in a .NET Framework application Sub Objective(s): Control the serialization of an object into XML format by using the System.Xml.Serialization namespace. References: MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework - Application Development Foundation, Second Edition Chapter 5 - Lesson 2 and 3 Introducing XML Serialization MSDN Library Link: http://msdn.microsoft.com/library/182eeyhh.aspx XmlSerializer Class MSDN Library Link: http://msdn.microsoft.com/library/system.xml.serialization.xmlserializer.aspx

TS: Microsoft .NET Framework, Application Development Foundation


Question Number (ID) : 12 (536P_5.4_07)

______________________________________________________________________________________________________________ You are reviewing a colleague's code for security vulnerabilities. Which of the following System.Security.Cryptography classes indicates that the developer was using weak encryption that could potentially be cracked in a short amount of time?

1. TripleDES 2. DES 3. RijndaelManaged 4. RC2 <Correct>

Explanation: The Data Encryption Standard (DES) is a symmetric encryption algorithm that uses relatively short key lengths that are vulnerable to cracking attacks. For that reason, it should be avoided. RijndaelManaged, an implementation of Advanced Encryption Standard (AES), is a strong government encryption standard and is the only .NET Framework symmetric encryption class that is fully managed. All other encryption classes call unmanaged code. Because of this, RijndaelManaged is the preferred choice when your application will be running in a partially trusted environment. RC2 is an encryption standard designed to replace DES that uses variable key sizes. It is more secure than DES. TripleDES is the .NET Framework implementation of the Triple DES symmetric encryption algorithm. It essentially applies the DES algorithm three times. It is approximately twice as strong as standard DES.

Objective: Improving the security of .NET Framework applications by using the .NET Framework security features Sub Objective(s): Encrypt, decrypt, and hash data by using the System.Security.Cryptography classes. References: MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework - Application Development Foundation, Second Edition Chapter 12 - Lesson 3 Cryptography Overview MSDN Library Link: http://msdn.microsoft.com/library/92f9ye3s.aspx SymmetricAlgorithm Class MSDN Library Link: http://msdn.microsoft.com/library/system.security.cryptography.symmetricalgorithm.aspx

TS: Microsoft .NET Framework, Application Development Foundation


Question Number (ID) : 13 (536P_6.1_03)

______________________________________________________________________________________________________________ You are creating an assembly that references a Component Object Model (COM) object. To ensure that the COM object is available and properly referenced, you want to perform early-bound activation. Which of the following C# code samples correctly activates an instance of the MyLib.MyClass coclass?

1. using System; using MyLib; public class MyApp { public static void Main(String[] Args) { MyClass mc = new MyClass(); // TODO: Complete application } } <Correct> 2. using System; using MyLib; public class MyApp { public static void Main(String[] Args) { activate MyClass // TODO: Complete application } } 3. using System; using MyLib; preload MyLib; public class MyApp { public static void Main(String[] Args) { // TODO: Complete application } } 4. using System; using MyLib; public class MyApp { load MyClass; public static void Main(String[] Args) { // TODO: Complete application } }

Explanation: To perform early-bound activation, simply create an instance of the class. When a .NET Framework client creates an instance of a coclass, the runtime must locate its metadata, regardless of whether the class is a .NET Framework class or a COM coclass. Metadata must be available at runtime to early-bind to a class. Metadata is not required for late-bound activation. There are no Load, Preload, or Activate keywords.

Objective: Implementing interoperability, reflection, and mailing functionality in a .NET Framework application Sub Objective(s): Expose COM components to the .NET Framework and .NET Framework components to COM. References: MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework - Application Development Foundation, Second Edition

Chapter 13 - Lesson 1 Activating a COM Object MSDN Library Link: http://msdn.microsoft.com/library/7c01w25h.aspx

TS: Microsoft .NET Framework, Application Development Foundation


Question Number (ID) : 14 (536P_7.1_07)

______________________________________________________________________________________________________________ Which of the following types would you create an instance of first to define a custom culture?

1. CultureAndRegionModifier 2. CultureInfo 3. CultureAndRegionInfoBuilder 4. CultureTypes <Correct>

Explanation: The CultureAndRegionInfoBuilder class defines a custom culture that is new or based on an existing culture and region. The custom culture can be installed on a computer and subsequently used by any application running on that computer. The CultureInfo class provides information about a specific culture. Once you have defined a custom culture with CultureAndRegionInfoBuilder, you can create a CultureInfo object based on the custom class. However, you must define CultureAndRegionInfoBuilder first. The CultureAndRegionModifiers enumeration specifies constants that define a CultureAndRegionInfoBuilder object. The CultureTypes enumeration defines the types of culture lists that can be retrieved using CultureInfo.GetCultures.

Objective: Implementing globalization, drawing, and text manipulation functionality in a .NET Framework application Sub Objective(s): Format data based on culture information. References: MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework - Application Development Foundation, Second Edition Chapter 16 - Lesson 1 How to: Create Custom Cultures MSDN Library Link: http://msdn.microsoft.com/library/ms172469.aspx

TS: Microsoft .NET Framework, Application Development Foundation


Question Number (ID) : 15 (536P_1.4_04)

______________________________________________________________________________________________________________ In C#, which of the following code samples compiles correctly?

1. StringDictionary dict = new StringDictionary(); dict["First"] = "1st"; <Correct> 2. StringDictionary dict = new StringDictionary(); dict[4] = 4; 3. StringDictionary dict = new StringDictionary(); dict[2] = "2"; 4. StringDictionary dict = new StringDictionary(); dict["3"] = 3;

Explanation: When you create an instance of the specialized StringDictionary class, you can set only values that are strings, and you can use only string indexes. Visual Basic automatically converts values to strings; however, you should still use the StringDictionary class only when both the index and the value are strings.

Objective: Developing applications that use system types and collections Sub Objective(s): Manage data in a .NET Framework application by using specialized collections. References: MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework - Application Development Foundation, Second Edition Chapter 4 - Lesson 1 StringDictionary Class MSDN Library Link: http://msdn.microsoft.com/library/system.collections.specialized.stringdictionary.aspx

TS: Microsoft .NET Framework, Application Development Foundation


Question Number (ID) : 16 (536P_2.2_08)

______________________________________________________________________________________________________________ Given the following C# code sample, how could you display the contents of the host string in the ProcessDnsInformation method? AsyncCallback callBack = new AsyncCallback(ProcessDnsInformation); string host = Console.ReadLine(); Dns.BeginGetHostEntry(host, callBack, host); 1. static void ProcessDnsInformation(IAsyncResult result) { Console.WriteLine(result.AsyncState); }

2. static void ProcessDnsInformation(IAsyncResult result) { Console.WriteLine((string)result.AsyncState); } <Correct> 3. static void ProcessDnsInformation(IAsyncResult result, string host) { Console.WriteLine(host); }

4. static void ProcessDnsInformation(IAsyncResult result) { Console.WriteLine(result.ToString()); }

Explanation: If you provide an AsyncCallback delegate, you can provide an object when creating the asynchronous request. This object is not processed during the request and is simply passed to the method specified to handle the completed request. The object is stored in IAsyncResult.AsyncState, and you must cast or convert it to the proper type. AsyncCallback delegates always accept a single parameter: an IAsyncResult object.

Objective: Implementing service processes, threading, and application domains in a .NET Framework application Sub Objective(s): Develop multithreaded .NET applications. References: MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework - Application Development Foundation, Second Edition Chapter 7 - Lesson 1 Using an AsyncCallback Delegate to End an Asynchronous Operation MSDN Library Link: http://msdn.microsoft.com/library/ms228972.aspx

TS: Microsoft .NET Framework, Application Development Foundation


Question Number (ID) : 17 (536P_3.6_03)

______________________________________________________________________________________________________________ You are creating a tool for the IT department that displays the media access control address and description of every network adapter on a remote computer with the Internet Protocol address 192.168.1.200. Which of the following C# code samples does this correctly?

1. ConnectionOptions co = new ConnectionOptions(@"\\192.168.1.200"); ObjectQuery oq = new ObjectQuery( "SELECT * FROM Win32_NetworkAdapterConfiguration"); ManagementObjectSearcher mos = new ManagementObjectSearcher(co, oq); ManagementObjectCollection moc = mos.Get(); foreach (ManagementObject mo in moc) Console.WriteLine(mo["MacAddress"] + ": " + mo["Description"]);

2. ManagementScope ms = new ManagementScope(@"\\192.168.1.200\root\cimv2"); ObjectQuery oq = new ObjectQuery( "SELECT * FROM Win32_NetworkAdapterConfiguration"); ManagementObjectSearcher mos = new ManagementObjectSearcher(ms, oq); ManagementObjectCollection moc = mos.Get(); foreach (ManagementObject mo in moc) Console.WriteLine(mo["MacAddress"] + ": " + mo["Description"]); <Correct> 3. ConnectionOptions co = new ConnectionOptions(@"\\192.168.1.200\root\cimv2"); ObjectQuery oq = new ObjectQuery( "SELECT * FROM Win32_NetworkAdapterConfiguration"); ManagementObjectSearcher mos = new ManagementObjectSearcher(co, oq); ManagementObjectCollection moc = mos.Get(); foreach (ManagementObject mo in moc) Console.WriteLine(mo["MacAddress"] + ": " + mo["Description"]);

4. ManagementScope ms = new ManagementScope(@"\\192.168.1.200"); ObjectQuery oq = new ObjectQuery( "SELECT * FROM Win32_NetworkAdapterConfiguration"); ManagementObjectSearcher mos = new ManagementObjectSearcher(ms, oq); ManagementObjectCollection moc = mos.Get(); foreach (ManagementObject mo in moc) Console.WriteLine(mo["MacAddress"] + ": " + mo["Description"]);

Explanation: To query running network adapters on a remote computer, perform the following steps: 1. Create a ManagementScope object to define the remote computer. The scope is not simply the computer name, however. It must be in the form "\\computername\root\cim2". 2. Create an instance of ObjectQuery using a Windows Management Instrumentation (WMI) query. The WMI query must be in the form "SELECT fields FROM Win32_NetworkAdapterConfiguration". 3. Create an instance of ManagementObjectSearcher by providing both the scope and the query.

4. Create an instance of ManagementObjectCollection by calling the ManagementObjectSearcher.Get method. You can then iterate through the ManagementObject objects in the ManagementObjectCollection to examine individual network adapters. You can create a ConnectionsOptions object if you want to specify a username and password. However, you cannot use a ConnectionsOptions object in place of a ManagementScope object.

Objective: Embedding configuration, diagnostic, management, and installation features into a .NET Framework application Sub Objective(s): Embed management information and events into a .NET Framework application. References: MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework - Application Development Foundation, Second Edition Chapter 10 - Lesson 3 ManagementObjectSearcher Class MSDN Library Link: http://msdn.microsoft.com/library/system.management.managementobjectsearcher.aspx ObjectQuery Class MSDN Library Link: http://msdn.microsoft.com/library/system.management.objectquery.aspx ManagementObjectCollection Class MSDN Library Link: http://msdn.microsoft.com/library/system.management.managementobjectcollection.aspx WMI .NET Overview MSDN Library Link: http://msdn.microsoft.com/library/ms257340.aspx

TS: Microsoft .NET Framework, Application Development Foundation


Question Number (ID) : 18 (536P_4.2_03)

______________________________________________________________________________________________________________ Which of the following C# code samples correctly deserializes the current date and time from an Extensible Markup Language (XML) file? 1. FileStream fs = new FileStream("SerializedDate.XML", FileMode.Open); XmlSerializer xs = new XmlSerializer(typeof(DateTime)); DateTime t = (DateTime)xs.Deserialize(fs); <Correct> 2. FileStream fs = new FileStream("SerializedDate.XML", FileMode.Open); XmlSerializer xs = new XmlSerializer(fs); DateTime t = (DateTime)xs.Deserialize();

3. FileStream fs = new FileStream("SerializedDate.XML", FileMode.Open); XmlSerializer xs = new XmlSerializer(); DateTime t = (DateTime)xs.Deserialize(fs);

4. FileStream fs = new FileStream("SerializedDate.XML", FileMode.Open); DateTime t = (DateTime)XmlSerializer.Read(fs);

Explanation: To deserialize an object, first create a Stream, TextReader, or XmlReader object to read the serialized input. Then create an XmlSerializer object (in the System.Xml.Serialization namespace) by passing it the type of object you plan to deserialize. Finally, call the XmlSerializer.Deserialize method to deserialize the object, and cast it to the correct type. No overload for the XmlSerializer constructor takes zero parameters. There is no static XmlSerializer.Read method. The XmlSerializer constructor requires a Type object and cannot accept a FileStream object.

Objective: Implementing serialization and input/output functionality in a .NET Framework application Sub Objective(s): Control the serialization of an object into XML format by using the System.Xml.Serialization namespace. References: MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework - Application Development Foundation, Second Edition Chapter 5 - Lessons 2 and 3 Basic Serialization MSDN Library Link: http://msdn.microsoft.com/library/4abbf6k0.aspx XmlSerializer Class MSDN Library Link: http://msdn.microsoft.com/library/system.xml.serialization.xmlserializer.aspx Introducing XML Serialization MSDN Library Link: http://msdn.microsoft.com/library/182eeyhh.aspx

TS: Microsoft .NET Framework, Application Development Foundation


Question Number (ID) : 19 (536P_5.5_03)

______________________________________________________________________________________________________________ Your IT department has requested your assistance. They have asked you to write a Console application that analyzes the C:\Boot.ini file on a Windows XP system to determine whether it is properly configured. The IT department will deploy your tool with administrative privileges, and you want to minimize the risk that the application will be abused to perform unauthorized tasks. Which of the following C# attributes would you use to minimize the security risk by limiting the assembly's privileges so that it can access only the C:\Boot.ini file?

1.

[assembly:FileIOPermissionAttribute(SecurityAction.RequestMinimum)]

2. [assembly:FileIOPermissionAttribute(SecurityAction.RequestMinimum, Read=@"C:\boot.ini")] 3. [assembly:FileIOPermissionAttribute(SecurityAction.PermitOnly, Read=@"C:\boot.ini")] 4. [assembly:FileIOPermissionAttribute(SecurityAction.RequestOptional, Read=@"C:\boot.ini")] <Correct>

Explanation: For declarative security attributes, use SecurityAction.RequestOptional to list only the code access security permissions that your application should have. In addition, you might want to use SecurityAction.RequestMinimum to cause the runtime to throw an exception if the assembly lacks the required permission. SecurityAction.PermitOnly cannot be used in declarative attributes. SecurityAction.RequestMinimum causes the runtime to throw an exception if the runtime lacks the listed permissions. However, it does not cause the runtime to reduce the assembly's permissions.

Objective: Improving the security of .NET Framework applications by using the .NET Framework security features Sub Objective(s): Control permissions for resources by using the System.Security.Permission classes. References: MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework - Application Development Foundation, Second Edition Chapter 11 - Lesson 3 Assemblies Should Declare Minimum Security MSDN Library Link: http://msdn.microsoft.com/library/ms182325.aspx SecurityAction Enumeration MSDN Library Link: http://msdn.microsoft.com/library/system.security.permissions.securityaction.aspx

TS: Microsoft .NET Framework, Application Development Foundation


Question Number (ID) : 20 (536P_6.2_04)

______________________________________________________________________________________________________________ Which of the following managed classes corresponds to the unmanaged HANDLE type?

1. Double 2. Int32 3. String 4. UInt16 5. IntPtr <Correct>

Explanation: The IntPtr managed class corresponds to the HANDLE unmanaged type. LPSTR corresponds to the String managed class. The UInt16 managed class corresponds to the WORD unmanaged type. The Int32 managed class corresponds to the INT, LONG, and BOOL unmanaged types. The Double managed class corresponds to the DOUBLE unmanaged type.

Objective: Implementing interoperability, reflection, and mailing functionality in a .NET Framework application Sub Objective(s): Call unmanaged DLL functions within a .NET Framework application, and control the marshalling of data in a .NET Framework application. References: MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework - Application Development Foundation, Second Edition Chapter 13 - Lesson 2 Platform Invoke Data Types MSDN Library Link: http://msdn.microsoft.com/library/ac7ay120.aspx

TS: Microsoft .NET Framework, Application Development Foundation


Question Number (ID) : 21 (536P_7.1_09)

______________________________________________________________________________________________________________ You are creating a Microsoft Windows service. Which of the following security contexts should you specify for the Account property to reduce security risks by running as a nonprivileged user while presenting anonymous credentials to network resources?

1. NetworkService 2. LocalSystem 3. LocalService 4. User <Correct>

Explanation: LocalService runs in the context of an account that acts as a nonprivileged user on the local computer, and it presents anonymous credentials to any remote server. User causes the system to prompt for a valid username and password when the service is installed, and it runs in the context of an account specified by a single user on the network. LocalSystem runs in the context of an account that provides extensive local privileges, and it presents the computer's credentials to any remote server. NetworkService runs in the context of an account that acts as a nonprivileged user on the local computer, and it presents the computer's credentials (not a specific user's credentials) to any remote server.

Objective: Implementing globalization, drawing, and text manipulation functionality in a .NET Framework application Sub Objective(s): Format data based on culture information. References: MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework - Application Development Foundation, Second Edition Chapter 16 - Lesson 1 How to: Specify the Security Context for Services MSDN Library Link: http://msdn.microsoft.com/library/0x72fzyf.aspx

TS: Microsoft .NET Framework, Application Development Foundation


Question Number (ID) : 22 (536P_1.4_08)

______________________________________________________________________________________________________________ You are writing an application that analyzes Internet Protocol (IP) subnets and makes recommendations about how to use an address space most efficiently. IP addresses are 32-bit values, and you need to be able to analyze individual bits and perform boolean arithmetic. Which of the following classes would be most efficient?

1. BitArray 2. Boolean 3. ArrayList 4. BitVector32 <Correct>

Explanation: The purpose of the BitVector32 structure is to aid in manipulating bits in a 32-bit integer, and it is perfect for IP addresses. The BitArray class is a resizable collection that can store boolean values. In addition to being resizable, it supports common bit -level operations such as AND, NOT, OR, and XOR (exclusive-or). However, you have more flexibility when working with a BitVector32 structure than a 32-bit BitArray instance. Boolean is a single-bit value. You would need to separately access 32 boolean variables, which would not be efficient. ArrayList does not support boolean math.

Objective: Developing applications that use system types and collections Sub Objective(s): Manage data in a .NET Framework application by using specialized collections. References: MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework - Application Development Foundation, Second Edition Chapter 4 - Lesson 1 BitVector32 Structure MSDN Library Link: http://msdn.microsoft.com/library/system.collections.specialized.bitvector32.aspx

TS: Microsoft .NET Framework, Application Development Foundation


Question Number (ID) : 23 (536P_2.2_01)

______________________________________________________________________________________________________________ You have written a multithreaded application for.NET Framework version 3.5. What happens if an unhandled exception occurs in a thread you start?

1. The runtime provides a backstop for the unhandled exception. 2. The exception is forwarded to the main thread. 3. The runtime terminates the application. 4. The runtime ignores the exception and continues running the thread. <Correct>

Explanation: The runtime forwards the exception to the parent thread in.NET Framework version 2.0 and later. In.NET Framework versions 1.0 and 1.1, the runtime provides a backstop for unhandled exceptions in child threads. However, this behavior has changed beginning with.NET Framework version 2.0. Unhandled exceptions often result in terminating the application; however, the parent process does have the opportunity to handle the exception. The runtime does not ignore exceptions under any circumstances.

Objective: Implementing service processes, threading, and application domains in a .NET Framework application Sub Objective(s): Develop multithreaded .NET applications. References: MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework - Application Development Foundation, Second Edition Chapter 7 - Lesson 2 Exceptions in Managed Threads MSDN Library Link: http://msdn.microsoft.com/library/ms228965.aspx

TS: Microsoft .NET Framework, Application Development Foundation


Question Number (ID) : 24 (536P_3.5_01)

______________________________________________________________________________________________________________ You are in the process of isolating a complicated bug in a Console application that occurs only in rare circumstances. You would like to pause execution to examine the values of variables during debugging, but you do not want to pause execution when users run release versions of the application. Which method should you call?

1. Debugger.Break 2. Console.ReadLine 3. Console.Read 4. Debug.Assert

<Correct>

Explanation: Debugger.Break acts just like a hard-coded breakpoint, except that you can call it programmatically. The Debugger class is only used in debug releases. Console.Read and Console.ReadLine interrupt processing in both debug and release versions of code. Debug.Assert validates a value and does not stop execution during debugging.

Objective: Embedding configuration, diagnostic, management, and installation features into a .NET Framework application Sub Objective(s): Debug and trace a .NET Framework application by using the System.Diagnostics namespace. References: MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework - Application Development Foundation, Second Edition Chapter 10 - Lesson 1 Debugger.Break Method MSDN Library Link: http://msdn.microsoft.com/library/system.diagnostics.debugger.break.aspx

TS: Microsoft .NET Framework, Application Development Foundation


Question Number (ID) : 25 (536P_4.6_01)

______________________________________________________________________________________________________________ Which of the following C# code samples correctly creates a new file named Hello.dat and writes the string "Hello, world!" to it?

1. FileStream fs = new FileStream("Hello.dat", FileMode.CreateNew); BinaryWriter bw = new BinaryWriter(fs); bw.BaseStream.Write("Hello, world!"); bw.Close(); fs.Close();

2. FileStream fs = new FileStream("Hello.dat", FileMode.CreateNew); BinaryWriter bw = new BinaryWriter(fs); bw.Write("Hello, world!"); bw.Close(); fs.Close(); <Correct> 3. FileStream fs = new FileStream("Hello.dat", FileMode.CreateNew); BinaryWriter bw = new BinaryWriter(fs); fs.Write("Hello, world!"); bw.Close(); fs.Close(); 4. BinaryWriter bw = new BinaryWriter("Hello.dat", FileMode.CreateNew); bw.Write("Hello, world!"); bw.Close();

Explanation: To write to a file with BinaryWriter, first create a FileStream object and use that to create the BinaryWriter object. Then call the BinaryWriter.Write method. Finally, close both the BinaryWriter object and the FileStream object. You can write directly to a FileStream object; however, the FileStream.Write method does not accept a string parameter. You cannot use a BinaryWriter object without creating a FileStream object first.

Objective: Implementing serialization and input/output functionality in a .NET Framework application Sub Objective(s): Manage .NET Framework application data by using Reader and Writer classes. References: MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework - Application Development Foundation, Second Edition Chapter 2 - Lesson 2 How to: Read and Write to a Newly Created Data File MSDN Library Link: http://msdn.microsoft.com/library/36b93480.aspx

TS: Microsoft .NET Framework, Application Development Foundation


Question Number (ID) : 26 (536P_5.6_05)

______________________________________________________________________________________________________________ Place the security policy levels in order from highest to lowest. From the list on the right, select valid policy levels. Place your selections in the list on the left in order from highest to lowest. Place your selections in the list on the left by clicking the items in the list on the right and clicking the arrow. You can also use the Up and Down buttons to rearrange items in the list on the left. You might not need to use all the items from the list on the right. Explanation: The highest level of security policy is enterprise-wide. Successive lower levels of hierarchy represent further policy restrictions, but they can never grant more permissions than allowed by higher levels. The following policy levels are implemented: 1. Enterprise: security policy for all managed code in an enterprise 2. Machine: security policy for all managed code that is run on the computer 3. User: security policy for all managed code that is run by the user 4. Application domain: security policy for all managed code in an application There is no Application policy level.

Objective: Improving the security of .NET Framework applications by using the .NET Framework security features Sub Objective(s): Control code privileges by using System.Security.Policy classes. References: MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework - Application Development Foundation, Second Edition Chapter 11 - Lesson 1 PolicyLevel Class MSDN Library Link: http://msdn.microsoft.com/library/system.security.policy.policylevel.aspx

TS: Microsoft .NET Framework, Application Development Foundation


Question Number (ID) : 27 (536P_6.4_03)

______________________________________________________________________________________________________________ You are writing an application that needs to transmit e-mail messages through a standard Simple Mail Transfer Protocol (SMTP) server, as well as perform other actions. To ensure that administrators configure the application with the appropriate permissions, you want to declare the required permission. You do not want to affect the permissions granted to the assembly, however. Which of the following declarations accomplishes this most effectively? 1. [assembly:SmtpPermission(SecurityAction.RequestMinimum, Access="Connect")] <Correct>

2. [assembly:SmtpPermission(SecurityAction.RequestMinimum, Access="ConnectToUnrestrictedPort")] 3. [assembly:SmtpPermission(SecurityAction.RequestOptional, Access="Connect")]

4. [assembly:SmtpPermission(SecurityAction.RequestOptional, Access="ConnectToUnrestrictedPort")]

Explanation: Use SecurityAction.RequestMinimum to demand specific permissions and to declare them for administrators. SmtpAccess.Connect is the most precise access declaration available. Using SmtpAccess.ConnectToUnrestrictedPort enables the assembly to connect to nonstandard SMTP servers, which is unnecessary in this example. In addition, SecurityAction.RequestOptional causes the runtime to revoke all permissions except those specifically listed. The question stated that you did not want to affect the assembly's permissions.

Objective: Implementing interoperability, reflection, and mailing functionality in a .NET Framework application Sub Objective(s): Send electronic mail to a Simple Mail Transfer Protocol (SMTP) server for delivery from a .NET Framework application. References: MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework - Application Development Foundation, Second Edition Chapter 15 - Lesson 2 SmtpPermission Class MSDN Library Link: http://msdn.microsoft.com/library/system.net.mail.smtppermission(VS.80).aspx SmtpAccess Enumeration MSDN Library Link: http://msdn.microsoft.com/library/system.net.mail.smtpaccess(VS.80).aspx

TS: Microsoft .NET Framework, Application Development Foundation


Question Number (ID) : 28 (536P_7.1_01)

______________________________________________________________________________________________________________ You are writing an English-language client application that must process data files generated by a server application. The server application runs at your organization's office in Sweden and was developed locally. How can you change the culture of your C# application to ensure the data file is processed correctly?

1. Thread.CurrentThread.CurrentCulture = new CultureInfo("sv-SE"); <Correct> 2. CultureInfo.CurrentCulture = "sv-SE"; 3. CultureInfo.CurrentCulture = new CultureInfo("sv-SE"); 4. Thread.CurrentThread.CurrentCulture.Name = "sv-SE";

Explanation: To modify the culture setting, set the Thread.CurrentThread.CurrentCulture property using a CultureInfo object. CultureInfo.CurrentCulture is read-only. CultureInfo.CurrentCulture is read-only and is of type CultureInfo. Thread.CurrentThread.CurrentCulture.Name is a read-only property.

Objective: Implementing globalization, drawing, and text manipulation functionality in a .NET Framework application Sub Objective(s): Format data based on culture information. References: MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework - Application Development Foundation, Second Edition Chapter 16 - Lesson 1 CultureInfo Class MSDN Library Link: http://msdn.microsoft.com/library/system.globalization.cultureinfo.aspx

TS: Microsoft .NET Framework, Application Development Foundation


Question Number (ID) : 29 (536P_1.6_08)

______________________________________________________________________________________________________________ Which of the following are events for the System.Windows.Forms.Button class? (Choose three.)

1. Resize 2. Serializing 3. MouseOver 4. Click 5. MouseHover 6. Enter <Correct> <Correct> <Correct>

Explanation: Click, Enter, and MouseHover are all valid events for the System.Windows.Forms.Button class. MouseOver, Resize, and Serializing are not events for the Button class.

Objective: Developing applications that use system types and collections Sub Objective(s): Control interactions between .NET Framework application components by using events and delegates. References: MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework - Application Development Foundation, Second Edition Chapter 1 - Lesson 3 Button Class MSDN Library Link: http://msdn.microsoft.com/library/system.windows.forms.button.aspx

TS: Microsoft .NET Framework, Application Development Foundation


Question Number (ID) : 30 (536P_2.3_05)

______________________________________________________________________________________________________________ Which of the following would you examine to determine whether the currently running assembly has permission to download assemblies via Hypertext Transfer Protocol (HTTP)? 1. 2. 3. 4. AppDomainSetup.CurrentDomain.DisallowCodeDownload AppDomain.CurrentDomain.DisallowCodeDownload this.SetupInformation.DisallowCodeDownload AppDomain.CurrentDomain.SetupInformation.DisallowCodeDownload <Correct>

Explanation: To determine whether the currently running assembly has permission to download assemblies via HTTP, examine the AppDomain.CurrentDomain.SetupInformation.DisallowCodeDownload object.

Objective: Implementing service processes, threading, and application domains in a .NET Framework application Sub Objective(s): Create a unit of isolation for common language runtime within a .NET Framework application by using application domains. References: MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework - Application Development Foundation, Second Edition Chapter 8 - Lesson 2 AppDomain Class MSDN Library Link: http://msdn.microsoft.com/library/system.appdomain.aspx

TS: Microsoft .NET Framework, Application Development Foundation


Question Number (ID) : 31 (536P_3.6_02)

______________________________________________________________________________________________________________ As a favor to your IT department, you are writing a Console application that outputs information related to the security of the current computer. Which of the following C# code samples correctly displays running services?

1. ObjectQuery oq = new ObjectQuery( "SELECT Caption FROM Win32_Service WHERE Started = FALSE"); ManagementObjectSearcher mos = new ManagementObjectSearcher(oq); ManagementObjectCollection moc = mos.Get(); foreach (ManagementObject mo in moc) Console.WriteLine(mo["Caption"]); 2. ObjectQuery oq = new ObjectQuery( "SELECT Caption FROM Win32_Service WHERE Started = TRUE"); ManagementObjectSearcher mos = new ManagementObjectSearcher(oq); ManagementObjectCollection moc = mos.Query(); foreach (ManagementObject mo in moc) Console.WriteLine(mo["Caption"]);

3. ObjectQuery oq = new ObjectQuery( "SELECT Caption FROM Win32_Service WHERE Started = FALSE"); ManagementObjectSearcher mos = new ManagementObjectSearcher(oq); ManagementObjectCollection moc = mos.Query(); foreach (ManagementObject mo in moc) Console.WriteLine(mo["Caption"]);

4. ObjectQuery oq = new ObjectQuery( "SELECT Caption FROM Win32_Service WHERE Started = TRUE"); ManagementObjectSearcher mos = new ManagementObjectSearcher(oq); ManagementObjectCollection moc = mos.Get(); foreach (ManagementObject mo in moc) Console.WriteLine(mo["Caption"]); <Correct>

Explanation: To query running services, perform the following steps: 1. Create an instance of ObjectQuery using a Windows Management Instrumentation (WMI) query. The WMI query must be in the form "SELECT fields FROM Win32_Service WHERE criteria". In this case, the criteria must be "WHERE Started = True" to return services that have started. 2. Create an instance of ManagementObjectSearcher based on the query. 3. Next, create an instance of ManagementObjectCollection by calling the ManagementObjectSearcher.Get method. You can then iterate through the ManagementObject objects in the ManagementObjectCollection to examine individual services. ManagementObjectSearcher.Query is a property used to define the query; it is not a method. You must use ManagementObjectSearcher.Get to run a query.

Objective: Embedding configuration, diagnostic, management, and installation features into a .NET Framework application

Sub Objective(s): Embed management information and events into a .NET Framework application. References: MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework - Application Development Foundation, Second Edition Chapter 10 - Lesson 3 ManagementObjectSearcher Class MSDN Library Link: http://msdn.microsoft.com/library/system.management.managementobjectsearcher.aspx ObjectQuery Class MSDN Library Link: http://msdn.microsoft.com/library/system.management.objectquery.aspx ManagementObjectCollection Class MSDN Library Link: http://msdn.microsoft.com/library/system.management.managementobjectcollection.aspx WMI .NET Overview MSDN Library Link: http://msdn.microsoft.com/library/ms257340.aspx

TS: Microsoft .NET Framework, Application Development Foundation


Question Number (ID) : 32 (536P_4.4_02)

______________________________________________________________________________________________________________ You need to create a directory if it does not yet exist. Of the following C# code samples, which most efficiently creates a directory without throwing an exception if it already exists? (If more than one code sample would work correctly, choose the sample that performs the desired task with the fewest lines of code.)

1. DirectoryInfo di = new DirectoryInfo(@"C:\dir\"); di.Create();

2. if (!Directory.Exists(@"C:\dir\")) Directory.CreateDirectory(@"C:\dir\");

3. DirectoryInfo di = new DirectoryInfo(@"C:\dir\"); if (!di.Exists) di.Create(); 4. Directory.CreateDirectory(@"C:\dir\"); <Correct>

Explanation: Each of these code samples creates a directory without causing the runtime to throw an exception if the directory already exists. The most efficient technique is to call the static Directory.CreateDirectory method. It is unnecessary to test whether a directory already exists before creating it.

Objective: Implementing serialization and input/output functionality in a .NET Framework application Sub Objective(s): Access files and folders by using the File System classes. References: MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework - Application Development Foundation, Second Edition Chapter 2 - Lesson 1 Directory Class MSDN Library Link: http://msdn.microsoft.com/library/system.io.directory.aspx DirectoryInfo Class MSDN Library Link: http://msdn.microsoft.com/en-us/library/system.io.directoryinfo.aspx

TS: Microsoft .NET Framework, Application Development Foundation


Question Number (ID) : 33 (536P_5.4_05)

______________________________________________________________________________________________________________ You are creating an assembly that needs to store private data to the disk. To protect the private data, you are encrypting it using asymmetric encryption. From the list on the right, select the tasks that you should perform to create and store a private encryption key. Place your selections in the list on the left in the order in which the tasks should be performed. Place your selections in the list on the left by clicking the items in the list on the right and clicking the arrow. You can also use the Up and Down buttons to rearrange items in the list on the left. You might not need to use all the items from the list on the right. Explanation: To store private keys persistently, you must create a CspParameters object, specify the CspParameters.KeyContainerName property, use that CspParameters object to create an RSACryptoServiceProvider object, and then set the RSACryptoServiceProvider.PersistKeyInCsp property to True. You cannot use the blank RSACryptoServiceProvider constructor first and then define the CspParameters object later. You must specify the CspParameters object during the RSACryptoServiceProvider construction. You do not need to set the RSACryptoServiceProvider.ExportParameters property to True.

Objective: Improving the security of .NET Framework applications by using the .NET Framework security features Sub Objective(s): Encrypt, decrypt, and hash data by using the System.Security.Cryptography classes. References: MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework - Application Development Foundation, Second Edition Chapter 12 - Lesson 3 How to: Store Asymmetric Keys in a Key Container MSDN Library Link: http://msdn.microsoft.com/library/tswxhw92.aspx

TS: Microsoft .NET Framework, Application Development Foundation


Question Number (ID) : 34 (536P_6.4_04)

______________________________________________________________________________________________________________ Your IT department has asked you to write a simple administrative tool. This tool will run automatically after the Boot.ini file has been modified on a system running Microsoft Windows XP. The tool must send the Boot.ini file as an e-mail attachment to the e-mail address ben@contoso.com. To reduce security risks, you want to grant your assembly the most restrictive permissions possible. Given the following C# code sample, which of the following security declarations should you use? (Choose all that apply.) MailMessage message = new MailMessage( "audit@contoso.com", "ben@contoso.com", "Modified system file", "See the attached file."); Attachment data = new Attachment(@"C:\Boot.ini", MediaTypeNames.Application.Octet); message.Attachments.Add(data); SmtpClient client = new SmtpClient("smtp.contoso.com", 1025); client.Send(message); data.Dispose(); 1. [assembly: FileIOPermission(SecurityAction.RequestOptional, Read = @"C:\ ")] 2. [assembly: SmtpPermission(SecurityAction.RequestOptional, Access = "Connect")] 3. [assembly: FileIOPermission(SecurityAction.RequestOptional, Read = @"C:\boot.ini")] <Correct> 4. [assembly: SmtpPermission(SecurityAction.RequestOptional, Access = "ConnectToUnrestrictedPort")] <Correct>

Explanation: This assembly requires two permissions: SmtpPermission and FileIOPermission. The most restrictive way that you can specify the SmtpPermission is to declare the ConnectToUnrestrictedPort access, because the code sample uses a nonstandard port number. The most restrictive way that you can specify the FileIOPermission is to specify Read access for the specific file. Specifying the Connect access level for SmtpPermission would not allow the application to run because it does not use the standard Simple Mail Transfer Protocol port of TCP 25. Specifying Read access to the entire C:\ drive is too general and would grant the assembly unnecessary privileges.

Objective: Implementing interoperability, reflection, and mailing functionality in a .NET Framework application Sub Objective(s): Send electronic mail to a Simple Mail Transfer Protocol (SMTP) server for delivery from a .NET Framework application. References: MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework - Application Development Foundation, Second Edition Chapter 15 - Lesson 2 MailMessage Class MSDN Library Link: http://msdn.microsoft.com/library/8t22a8ww(en-US,VS.80).aspx Assemblies Should Declare Minimum Security MSDN Library Link: http://msdn.microsoft.com/library/ms182325.aspx SecurityAction Enumeration

MSDN Library Link: http://msdn.microsoft.com/library/system.security.permissions.securityaction.aspx

TS: Microsoft .NET Framework, Application Development Foundation


Question Number (ID) : 35 (536P_7.1_10)

______________________________________________________________________________________________________________ You are creating a Microsoft Windows service. Which of the following security contexts should you specify for the Account property to reduce security risks by running as a nonprivileged user while presenting computer credentials to network resources?

1. User 2. NetworkService 3. LocalService 4. LocalSystem <Correct>

Explanation: NetworkService runs in the context of an account that acts as a nonprivileged user on the local computer, and it presents the computer's credentials (not a specific user's credentials) to any remote server. LocalService runs in the context of an account that acts as a nonprivileged user on the local computer, and it presents anonymous credentials to any remote server. User causes the system to prompt for a valid username and password when the service is installed, and it runs in the context of an account specified by a single user on the network. LocalSystem runs in the context of an account that provides extensive local privileges, and it presents the computer's credentials to any remote server.

Objective: Implementing globalization, drawing, and text manipulation functionality in a .NET Framework application Sub Objective(s): Format data based on culture information. References: MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework - Application Development Foundation, Second Edition Chapter 16 - Lesson 1 How to: Specify the Security Context for Services MSDN Library Link: http://msdn.microsoft.com/library/0x72fzyf.aspx

TS: Microsoft .NET Framework, Application Development Foundation


Question Number (ID) : 36 (536P_1.4_03)

______________________________________________________________________________________________________________ You write the following C# console application: NameValueCollection sl = new NameValueCollection(); sl.Add("Key", "One."); sl.Add("Key", "Two."); foreach (string s in sl.GetValues("Key")) Console.WriteLine(s); What is the output of this application? 1. Two. 2. The code fails to compile. 3. One. 4. One. Two. <Correct>

Explanation: This code compiles. The NameValueCollection class is a specialized dictionary that allows multiple values to be stored for a single key. By calling NameValueDictionary.GetValues, you can iterate through every value with a specific key.

Objective: Developing applications that use system types and collections Sub Objective(s): Manage data in a .NET Framework application by using specialized collections. References: MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework - Application Development Foundation, Second Edition Chapter 4 - Lesson 2 NameValueCollection Class MSDN Library Link: http://msdn.microsoft.com/library/system.collections.specialized.namevaluecollection.aspx

TS: Microsoft .NET Framework, Application Development Foundation


Question Number (ID) : 37 (536P_2.1_02)

______________________________________________________________________________________________________________ Which of the following is a valid reason to create a service?

1. Users must be able to run your application without Administrator privileges. 2. All users on the computer must be able to run your application. 3. Your application must start automatically when a user logs on. 4. You need to monitor an aspect of the operating system without a user logging on. <Correct>

Explanation: Services run in the background without requiring a user to log on. Therefore, they are perfect for monitoring the operating system or responding to events. Services are not run directly by users. Services can start automatically when the computer starts. To have an assembly start automatically when a user logs on, simply add a shortcut to the application to the user's Startup group.

Objective: Implementing service processes, threading, and application domains in a .NET Framework application Sub Objective(s): Implement, install, and control a service. References: MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework - Application Development Foundation, Second Edition Chapter 8 - Lesson 3 ServiceController Class MSDN Library Link: http://msdn.microsoft.com/library/system.serviceprocess.servicecontroller.aspx Introduction to Windows Service Applications MSDN Library Link: http://msdn.microsoft.com/library/d56de412.aspx

TS: Microsoft .NET Framework, Application Development Foundation


Question Number (ID) : 38 (536P_3.3_03)

______________________________________________________________________________________________________________ Which of the following C# code samples successfully writes the entire contents of the Application log to the console?

1. EventLog el = new EventLog(); el.Log = "Application"; foreach (EventLogEntry ele in el.Entries) Console.WriteLine(ele.Source + ":" + ele.Message); <Correct> 2. EventLog el = new EventLog(); foreach (EventLog ele in el.Entries) Console.WriteLine(ele.Source + ":" + ele.Message);

3. EventLog el = new EventLog(); foreach (EventLogEntry ele in el.Entries) Console.WriteLine(ele.Source + ":" + ele.Message);

4. EventLog el = new EventLog(); el.Log = "Application"; foreach (EventLog ele in el.Entries) Console.WriteLine(ele.Source + ":" + ele.Message);

Explanation: To read an entire log file, create an instance of the EventLog class, specify the EventLog.Log property, and then iterate through EventLog.Entries. EventLog.Entries is an EventLogEntryCollection property containing EventLogEntry objects.

Objective: Embedding configuration, diagnostic, management, and installation features into a .NET Framework application Sub Objective(s): Manage an event log by using the System.Diagnostics namespace. References: MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework - Application Development Foundation, Second Edition Chapter 10 - Lesson 1 EventLog Class MSDN Library Link: http://msdn.microsoft.com/library/system.diagnostics.eventlog.aspx Logging Application, Server, and Security Events MSDN Library Link: http://msdn.microsoft.com/library/e6t4tk09.aspx

TS: Microsoft .NET Framework, Application Development Foundation


Question Number (ID) : 39 (536P_4.6_02)

______________________________________________________________________________________________________________ You need to write text to a file. Which of the following C# code demonstrates the most efficient way to use the TextWriter class?

1. FileStream fs = new FileStream("Hello.dat", FileMode.Create); TextWriter tw = new StreamWriter(fs); tw.Write("Hello, world!"); tw.Close(); fs.Close(); <Correct> 2. TextWriter tw = new TextWriter("Hello.dat"); tw.Write("Hello, world!"); tw.Close();

3. TextWriter tw = new StreamWriter("Hello.dat"); tw.Write("Hello, world!"); tw.Close();

4. TextWriter tw = new FileStream("Hello.dat", FileMode.Create); tw.Write("Hello, world!"); tw.Close();

Explanation: The TextWriter class does not have a constructor. Instead, you should create it using the StreamWriter constructor. To create a StreamWriter object, you must use an existing Stream object, such as an instance of FileStream.

Objective: Implementing serialization and input/output functionality in a .NET Framework application Sub Objective(s): Manage .NET Framework application data by using Reader and Writer classes. References: MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework - Application Development Foundation, Second Edition Chapter 2 - Lesson 2 TextWriter Class MSDN Library Link: http://msdn.microsoft.com/library/system.io.textwriter.aspx

TS: Microsoft .NET Framework, Application Development Foundation


Question Number (ID) : 40 (536P_5.1_05)

______________________________________________________________________________________________________________ Which of the following If statements correctly identifies whether the current assembly has permission to read the C:\Boot.ini file? 1. if (SecurityManager.CheckExecutionRights (new FileIOPermission( FileIOPermissionAccess.Read, @"C:\boot.ini")))

2. if (SecurityManager.IsGranted (new FileIOPermission( FileIOPermissionAccess.Read, @"C:\boot.ini"))) <Correct> 3. if (SecurityManager.IsGranted( FileIOPermissionAccess.Read, @"C:\boot.ini"))

4. if (SecurityManager.CheckExecutionRights (FileIOPermissionAccess.Read, @"C:\boot.ini"))

Explanation: Use SecurityManager.IsGranted to determine imperatively whether the current process has a specific permission. You must provide a Permission object to SecurityManager.IsGranted. You cannot provide a FileIOPermissionAccess enumeration. SecurityManager.CheckExecutionRights only determines whether the process must have System.Security.Permissions.SecurityPermissionFlag.Execution to execute.

Objective: Improving the security of .NET Framework applications by using the .NET Framework security features Sub Objective(s): Implement code access security to improve the security of a .NET Framework application. References: MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework - Application Development Foundation, Second Edition Chapter 11 - Lesson 3 SecurityManager Class MSDN Library Link: http://msdn.microsoft.com/library/system.security.securitymanager.aspx

TS: Microsoft .NET Framework, Application Development Foundation


Question Number (ID) : 41 (536P_6.3_04)

______________________________________________________________________________________________________________ You are using reflection to load and run an assembly. You need to respond to an event initiated within the loaded assembly. From the list on the right, select the tasks that you should perform to respond to an event by using reflection. Place your selections in the list on the left in the order in which the tasks should be performed. Place your selections in the list on the left by clicking the items in the list on the right and clicking the arrow. You can also use the Up and Down buttons to rearrange items in the list on the left. You might not need to use all the items from the list on the right. Explanation: When you use reflection to load and run assemblies, you cannot use language features such as the C# += operator or the Visual Basic AddHandler keyword to hook up events. Instead, you must get all the necessary types through reflection.

Objective: Implementing interoperability, reflection, and mailing functionality in a .NET Framework application Sub Objective(s): Implement reflection functionality in a .NET Framework application, and create metadata, Microsoft intermediate language (MSIL), and a PE file by using the System.Reflection.Emit namespace. References: MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework - Application Development Foundation, Second Edition Chapter 14 - Lesson 1 How to: Hook Up a Delegate Using Reflection MSDN Library Link: http://msdn.microsoft.com/library/ms228976.aspx

TS: Microsoft .NET Framework, Application Development Foundation


Question Number (ID) : 42 (536P_7.3_05)

______________________________________________________________________________________________________________ You are writing a method that accepts dates as a string in mm/dd/yyyy format and returns the same date in yyyy-mm-dd format. Which of the following C# methods accomplishes this?

1. static string ReformatDate(string s) { Match m = Regex.Match(s, @"\b(?<month>\d{1,2})/(?<day>\d{1,2})/(?<year>\d{2,4})\b"); return m.Groups["year"] + "-" + m.Groups["month"] + "-" + m.Groups["day"]; } <Correct> 2. static string ReformatDate(string s) { Match m = Regex.Match(s, @"\b(<month>\d{1,2})/(<day>\d{1,2})/(<year>\d{2,4})\b"); return m.Groups["year"] + "-" + m.Groups["month"] + "-" + m.Groups["day"]; } 3. static string ReformatDate(string s) { Match m = Regex.Match(s, @"\b(<month>\d{1,2})/(<day>\d{1,2})/(<year>\d{2,4})\b"); return m.Groups[year] + "-" + m.Groups[month] + "-" + m.Groups[day]; } 4. static string ReformatDate(string s) { Match m = Regex.Match(s, @"\b(?<month>\d{1,2})/(?<day>\d{1,2})/(?<year>\d{2,4})\b"); return m.Groups[year] + "-" + m.Groups[month] + "-" + m.Groups[day]; }

Explanation: To extract information from a string, create a regular expression and surround the matched text with parentheses. In the case of a date number, you must match three groups of numbers, each separated by a slash. Months and days are two digits each, and the year can be one to four digits. Compare the date to the regular expression using Regex.Match. In this code sample, named groups are used. The year is placed in the "year" named group, the month in the "month" named group, and the day in the "day" named group. You can access each group from the Match.Groups collection using the group name, which must be in the form of a string with quotes.

Objective: Implementing globalization, drawing, and text manipulation functionality in a .NET Framework application Sub Objective(s): Enhance the text handling capabilities of a .NET Framework application, and search, modify, and control text within a .NET Framework application by using regular expressions. References: MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework - Application Development Foundation, Second Edition Chapter 3 - Lesson 1

Regular Expression Classes MSDN Library Link: http://msdn.microsoft.com/library/30wbz966.aspx Regex Class MSDN Library Link: http://msdn.microsoft.com/library/system.text.regularexpressions.regex.aspx

TS: Microsoft .NET Framework, Application Development Foundation


Question Number (ID) : 43 (536P_1.5_04)

______________________________________________________________________________________________________________ Given the following C# code sample, which interface must the custom class MyClass implement? MyClass a; bool b; a = 42; // Convert using ToBoolean. b = Convert.ToBoolean(a); Console.WriteLine("a = {0}, b = {1}", a.ToString(), b.ToString());

1. IConvertible 2. IComparable 3. ICloneable 4. IDisposable 5. IEquatable 6. IFormattable 7. INullableValue

<Correct>

Explanation: Use the IConvertible interface to enable a custom class to be converted to other types. Implementing the other interfaces does not allow a class to be converted.

Objective: Developing applications that use system types and collections Sub Objective(s): Implement .NET Framework interfaces to cause components to comply with standard contracts. References: MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework - Application Development Foundation, Second Edition Chapter 1 - Lesson 4 IConvertible Interface MSDN Library Link: http://msdn.microsoft.com/library/system.iconvertible.aspx

TS: Microsoft .NET Framework, Application Development Foundation


Question Number (ID) : 44 (536P_2.2_06)

______________________________________________________________________________________________________________ You are writing an application that needs to perform processing that will run for several hours. However, you need the application to remain responsive to the user during that time, so you are using multiple threads. Which of the following C# code samples starts the thread so as to minimize the impact on the performance of other applications?

1. ThreadStart myThreadDelegate = new ThreadStart( ThreadWork.DoWork, ThreadPriority.Lowest); Thread myThread = new Thread(myThreadDelegate); myThread.Start();

2. ThreadStart myThreadDelegate = new ThreadStart(ThreadWork.DoWork); Thread myThread = new Thread(myThreadDelegate); myThread.Priority = ThreadPriority.Lowest; myThread.Start(); <Correct> 3. ThreadStart myThreadDelegate = new ThreadStart(ThreadWork.DoWork); Thread myThread = new Thread(myThreadDelegate, ThreadPriority.Lowest); myThread.Start(); 4. ThreadStart myThreadDelegate = new ThreadStart(ThreadWork.DoWork); Thread myThread = new Thread(myThreadDelegate); myThread.StartLowPriority();

Explanation: Set the Thread.Priority property to control a thread's processing priority. The Thread.StartLowPriority method does not exist. You cannot pass a priority level to the Thread constructor. You cannot pass a priority level to the ThreadStart constructor.

Objective: Implementing service processes, threading, and application domains in a .NET Framework application Sub Objective(s): Develop multithreaded .NET applications. References: MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework - Application Development Foundation, Second Edition Chapter 7 - Lesson 1 Scheduling Threads MSDN Library Link: http://msdn.microsoft.com/library/2k34xtf3.aspx

TS: Microsoft .NET Framework, Application Development Foundation


Question Number (ID) : 45 (536P_3.1_03)

______________________________________________________________________________________________________________ Which class would you use to access programmatically the connection strings stored in the following configuration file? (The connection strings have been formatted to fit on multiple lines.) <?xml version="1.0" encoding="utf-8" ?> <configuration> <connectionStrings> <clear/> <add name="AdventureWorksString" providerName="System.Data.SqlClient" connectionString="Data Source=localhost; Initial Catalog=AdventureWorks; Integrated Security=true"/> <add name="MarsEnabledSqlServer2005String" providerName="System.Data.SqlClient" connectionString="Server=Aron1;Database=pubs; Trusted_Connection=True;MultipleActiveResultSets=true" /> <add name="OdbcConnectionString" providerName="System.Data.Odbc" connectionString="Driver={Microsoft Access Driver (*.mdb)}; Dbq=C:\adatabase.mdb;Uid=Admin; Pwd=R3m3emberToUseStrongPasswords;"/> </connectionStrings> </configuration> 1. ConfigurationSettings.ConnectionStrings

2. ConfigurationSection.ConnectionStrings 3. 4. ConfigurationProperty.ConnectionStrings ConfigurationManager.ConnectionStrings <Correct>

Explanation: Use ConfigurationManager.ConnectionStrings to access database connection strings. ConfigurationSettings is obsolete. ConfigurationSection does not have a ConnectionStrings property. ConfigurationProperty does not have a ConnectionStrings property.

Objective: Embedding configuration, diagnostic, management, and installation features into a .NET Framework application Sub Objective(s): Embed configuration management functionality into a .NET Framework application. References: MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework - Application Development Foundation, Second Edition Chapter 9 - Lesson 1 ConfigurationManager.ConnectionStrings Property MSDN Library Link: http://msdn.microsoft.com/library/system.configuration.configurationmanager.connectionstrings.aspx

You might also like