Top Banner
Practice Questions for Exam 70-536 This document contains practice questions that will help you prepare for exam 70-536. Contents Developing Applications That Use System Types and Collections........1 Implementing Service Processes, Threading, and Application Domains in a .NET Framework Application.........................................4 Embedding Configuration, Diagnostic, Management, and Installation Features into a .NET Framework Application...........................6 Implementing Serialization and Input/Output Functionality in a .NET Framework Application................................................ 8 Improving the Security of the .NET Framework Applications by Using the .NET Framework 2.0 Security Features................................11 Implementing Interoperability, Reflection, and Mailing Functionality in a .NET Framework Application.....................................15 Implementing Globalization, Drawing, and Text Manipulation Functionality in a .NET Framework Application.......................19 Developing Applications That Use System Types and Collections This section contains three practice questions that help prepare you to develop applications that include system types and collections. Question 1 Question 2 Question 3 QUESTION 1 You are creating a custom class that allocates large blocks of
26

Practice Questions for Exam 70 536

Apr 11, 2015

Download

Documents

anjangos

Microsoft Certificate
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Practice Questions for Exam 70 536

Practice Questions for Exam 70-536This document contains practice questions that will help you prepare for exam 70-536.

ContentsDeveloping Applications That Use System Types and Collections...............................................................1

Implementing Service Processes, Threading, and Application Domains in a .NET Framework Application.4

Embedding Configuration, Diagnostic, Management, and Installation Features into a .NET Framework Application..................................................................................................................................................6

Implementing Serialization and Input/Output Functionality in a .NET Framework Application..................8

Improving the Security of the .NET Framework Applications by Using the .NET Framework 2.0 Security Features.....................................................................................................................................................11

Implementing Interoperability, Reflection, and Mailing Functionality in a .NET Framework Application. 15

Implementing Globalization, Drawing, and Text Manipulation Functionality in a .NET Framework Application................................................................................................................................................19

Developing Applications That Use System Types and CollectionsThis section contains three practice questions that help prepare you to develop applications that include system types and collections.

Question 1 Question 2 Question 3

QUESTION 1You are creating a custom class that allocates large blocks of memory. Instead of waiting for the runtime to automatically free the resources, you want developers who use your class to be able to free resources on demand when an instance of the class is no longer needed. Which interface should you implement?

a) IComparable b) ICloneablec) IEquatabled) IFormattablee) IDisposable

Page 2: Practice Questions for Exam 70 536

f) INullableValueg) IConvertible

ANSWER 1e) IDisposable

QUESTION 2What is the purpose of a delegate?

a) To spawn an additional thread to provide parallel processingb) To copy member methods and properties from an existing classc) To enable an assembly to respond to an event that occurs within a classd) To provide identical member methods and properties from multiple related classes

ANSWER 2c) To enable an assembly to respond to an event that occurs within a class

QUESTION 3Which of the following code samples is a valid interface declaration?a) ' VB

Interface IAsset

Function SampleMethod() As Integer

Dim i As Integer = 5

Return i

End Function

End Interface

// C#

interface ISampleInterface

{

int SampleMethod()

{

int i = 5;

return i;

}

}

b) ' VB

Interface IAsset

Function SampleMethod() as Integer

End Interface

Page 3: Practice Questions for Exam 70 536

// C#

interface ISampleInterface

{

int SampleMethod();

}

c) ' VB

Interface IAsset

Private j As Integer = 5

Function SampleMethod() as Integer

End Interface

// C#

interface ISampleInterface

{

private int j = 5;

int SampleMethod();

}

d) ' VB

Interface IAsset(j as Integer)

Function SampleMethod() as Integer

End Interface

// C#

interface ISampleInterface(int j)

{

int SampleMethod();

}

ANSWER 3b) ' VB

Interface IAsset

Function SampleMethod() as Integer

End Interface

// C#

interface ISampleInterface

Page 4: Practice Questions for Exam 70 536

{

int SampleMethod();}

For a thorough explanation of the questions and answers shown here, as well as practice tests and a comprehensive study guide for exam 70-536, order the MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0—Application Development Foundation book from Microsoft Press.

Implementing Service Processes, Threading, and Application Domains in a .NET Framework ApplicationThis section contains three practice questions to help prepare you to implement service processes, threading, and application domains in a .NET Framework application.

Question 1 Question 2 Question 3

Question 1Which of the following code samples creates an application domain and launches a process within it?a) ' VB

Dim d As AppDomain = AppDomain.CreateDomain("Domain", "Assembly")

// C#AppDomain d = AppDomain.CreateDomain("Domain", "Assembly");

b) ' VBDim d As AppDomain = AppDomain.ExecuteAssemblyByName("Domain", "Assembly")

// C#AppDomain d = AppDomain.ExecuteAssemblyByName("Domain", "Assembly");

c) ' VBDim d As AppDomain = AppDomain.CreateDomain("Domain")d.ExecuteAssemblyByName("Assembly")

// C#AppDomain d = AppDomain.CreateDomain("Domain");d.ExecuteAssemblyByName("Assembly");

d) ' VBAppDomain.ExecuteAssemblyByName("Assembly")

// C#AppDomain.ExecuteAssemblyByName("Assembly");

Answer 1c) ' VB

Dim d As AppDomain = AppDomain.CreateDomain("Domain")d.ExecuteAssemblyByName("Assembly")

Page 5: Practice Questions for Exam 70 536

// C#AppDomain d = AppDomain.CreateDomain("Domain");d.ExecuteAssemblyByName("Assembly");

Question 2Which of the following code samples would successfully start the Server service?a) ' VB

Dim sc As ServiceController = New ServiceController("Server")sc.Start()

// C#ServiceController sc = new ServiceController("Server");sc.Start();

b) ' VBServiceController.Start("Server")

// C#ServiceController.Start("Server");

c) ' VBDim sc As ServiceController = New ServiceController()sc.Start("Server")

// C#ServiceController sc = new ServiceController();sc.Start("Server");

d) ' VBServiceController.Continue("Server")

// C#ServiceController.Continue("Server");

Answer 2a) ' VB

Dim sc As ServiceController = New ServiceController("Server")sc.Start()

// C#ServiceController sc = new ServiceController("Server");sc.Start();

Question 3You are writing managed code that will be executed within a thread. What do you need to do to enable your code to recover from a call to Thread.Sleep and a subsequent Thread.Interrupt call?

a) Respond to the parent process's On_Interrupt event.

Page 6: Practice Questions for Exam 70 536

b) Implement the IInterruptible interface.c) Catch the ThreadInterruptedException and do whatever is appropriate to continue working.

Answer 3c) Catch the ThreadInterruptedException and do whatever is appropriate to continue working.

For a thorough explanation of the questions and answers shown here, as well as practice tests and a comprehensive study guide for exam 70-536, order the MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0—Application Development Foundation book from Microsoft Press.

Embedding Configuration, Diagnostic, Management, and Installation Features into a .NET Framework ApplicationThis section contains two practice questions to help prepare you to configure, diagnose, manage, and install features into a .NET Framework application.

Question 1 Question 2

Question 1You are writing an application that must perform event logging. When is the correct time to create an event source?

a) Before you write each event.b) Before you write the first event.c) During installation.d) After you restart the computer.

Answer 1c) During installation

Question 2As part of a troubleshooting tool for the systems administrators at your organization, you are writing a command-line tool that automatically kills any unresponsive applications. Which of the following code samples accomplishes this?a) ' VB

For Each p As Process In Process.GetProcesses

If Not p.Responding Then

p.Kill

End If

Next

// C#

foreach (Process p in Process.GetProcesses())

Page 7: Practice Questions for Exam 70 536

if (!p.Responding)

p.Kill();

b) ' VB

For Each p As Process In Process.GetProcesses

If Not p.Responding Then

Process.Kill(p.Id)

End If

Next

// C#

foreach (Process p in Process.GetProcesses())

if (!p.Responding)

Process.Kill(p.Id);

c) ' VB

For Each p As Process In Process.GetUnresponsiveProcesses

p.Kill

Next

// C#

foreach (Process p in Process.GetUnresponsiveProcesses())

p.Kill();

d) ' VB

For Each p As Process In Process.GetUnresponsiveProcesses

Process.Kill(p.Id)

Next

// C#

foreach (Process p in Process.GetUnresponsiveProcesses())

Process.Kill(p.Id);

Answer 2a) ' VB

For Each p As Process In Process.GetProcesses

If Not p.Responding Then

p.Kill

End If

Next

Page 8: Practice Questions for Exam 70 536

// C#

foreach (Process p in Process.GetProcesses())

if (!p.Responding) p.Kill();

For a thorough explanation of the questions and answers shown here, as well as practice tests and a comprehensive study guide for exam 70-536, order the MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0—Application Development Foundation book from Microsoft Press.

Implementing Serialization and Input/Output Functionality in a .NET Framework ApplicationThis section contains five practice questions to help prepare you to implement serialization and input/output functionality in a .NET Framework application.

Question 1 Question 2 Question 3 Question 4 Question 5

Question 1You are responsible for an internal database application. Your organization would now like to selectively send information from the database to external customers using XML documents. Currently, you have custom classes that store this information. Which class should you use to write the XML documents?

a) BinaryFormatterb) TextWriterc) StreamWriterd) XmlSerializer

Answer 1d) XmlSerializer

Question 2You are adding a new member to a class that is already in use. You want to provide backward compatibility with serialized data that was created before the member was added. Which attribute would you add to the new member so that it would be serialized in the future, but de-serialization would not throw an exception if the member class was not present in the serialized data?

a) ISerializableb) OptionalFieldc) IDeserializationCallbackd) NonSerialized

Page 9: Practice Questions for Exam 70 536

Answer 2b) OptionalField

Question 3Which of the following code samples is the most efficient way to rename a file from "File1.txt" to "File2.txt"?a) ' VB

File.Move("File1.txt", "File2.txt")

// C#

File.Move("File1.txt", "File2.txt");

b) ' VB

File.Rename("File1.txt", "File2.txt")

// C#

File.Rename("File1.txt", "File2.txt");

c) ' VB

File.Copy("File1.txt", "File2.txt")

File.Delete("File1.txt")

// C#

File.Copy("File1.txt", "File2.txt");

File.Delete("File1.txt");

d) ' VB

File.Replace("File1.txt", "File2.txt")

// C#

File.Replace("File1.txt", "File2.txt");

Answer 3a) ' VB

File.Move("File1.txt", "File2.txt")

// C#File.Move("File1.txt", "File2.txt");

Question 4

Page 10: Practice Questions for Exam 70 536

You are working with your IT department to deploy an application that you wrote. The IT department asks if your application needs access to any folders that are on the local hard disk. Your application uses only isolated storage. Your application will be deployed only to new computers that are running Microsoft Windows XP. Your IT department does not use roaming profiles.

To which folder does your application require access?

a) <systemroot>\Profiles\<user>\Application Datab) <systemroot>\Application Datac) <systemdrive>\Documents and Settings\<user>\ Local Settings\Application Datad) <systemroot>\Documents and Settings\<user>\Application Data

Answer 4c) <systemdrive>\Documents and Settings\<user>\ Local Settings\Application Data

Question 5Which of the following classes interact with the file system? (Choose all that apply.)

a) FileStreamb) MemoryStreamc) StringReaderd) StreamReadere) SslStream

Answer 5a) FileStreamd) StreamReader

For a thorough explanation of the questions and answers shown here, as well as practice tests and a comprehensive study guide for exam 70-536, order the MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0—Application Development Foundation book from Microsoft Press.

Improving the Security of .NET Framework Applications by Using the .NET Framework 2.0 Security FeaturesThis section contains four practice questions to help prepare you to implement the security of .NET Framework applications by using .NET Framework 2.0 security features.

Question 1 Question 2 Question 3 Question 4

Question 1You are reviewing a colleague's code for security vulnerabilities. Which of the following

Page 11: Practice Questions for Exam 70 536

System.Security.Cryptography classes would indicate that the developer was using weak encryption that could potentially be cracked in a short amount of time?

a) RijndaeIManagedb) DESc) RC2d) TripleDES

Answer 1b) DES

Question 2Your IT department has requested your assistance. They have asked you to write a console application that analyzes the C:\Boot.ini file 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 another task. Which of the following 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?

a) ' VB

<Assembly: FileIOPermissionAttribute(SecurityAction.PermitOnly, Read := "C:\boot.ini")>

// C#

[assembly:FileIOPermissionAttribute(SecurityAction.PermitOnly, Read=@"C:\boot.ini")]

b) ' VB

<Assembly: FileIOPermissionAttribute(SecurityAction.RequestMinimum, Read := "C:\boot.ini")>

// C#

[assembly:FileIOPermissionAttribute(SecurityAction.RequestMinimum, Read=@"C:\boot.ini")]

c) ' VB

<Assembly: FileIOPermissionAttribute(SecurityAction.RequestOptional, Read := "C:\boot.ini")>

// C#

[assembly:FileIOPermissionAttribute(SecurityAction.RequestOptional, Read=@"C:\boot.ini")]

d) ' VB

<Assembly: FileIOPermissionAttribute(SecurityAction.RequestMinimum)>

// C#

[assembly:FileIOPermissionAttribute(SecurityAction.RequestMinimum)]

Answer 2

Page 12: Practice Questions for Exam 70 536

c) ' VB

<Assembly: FileIOPermissionAttribute(SecurityAction.RequestOptional, Read := "C:\boot.ini")>

// C#

[assembly:FileIOPermissionAttribute(SecurityAction.RequestOptional, Read=@"C:\boot.ini")]

Question 3You are writing an application that stores security log information in a text file. This log file contains confidential information that only members of the local Administrators group should be able to view or modify.

Which of the following code samples creates a text file that has the proper permissions?a) ' VB

Dim user As NTAccount = New NTAccount("Administrators")

Dim ar As FileSystemAccessRule = New FileSystemAccessRule(user, FileSystemRights.FullControl, AccessControlType.Allow)

Dim fs As FileSecurity = New FileSecurity

fs.AddAccessRule(ar)

System.IO.File.Create("log.txt", 1000, FileOptions.None, fs)

// C#

NTAccount user = new NTAccount("Administrators");

FileSystemAccessRule ar = new FileSystemAccessRule(user, FileSystemRights.FullControl, AccessControlType.Allow);

FileSecurity fs = new FileSecurity();

fs.AddAccessRule(ar);

System.IO.File.Create("log.txt", 1000, FileOptions.None, fs);

b) ' VB

Dim user As NTAccount = New NTAccount("Administrator")

Dim ar As FileSystemAccessRule = New FileSystemAccessRule(user, FileSystemRights.FullControl, AccessControlType.Allow)

Dim fs As FileSecurity = New FileSecurity

fs.AddAccessRule(ar)

System.IO.File.Create("log.txt", 1000, FileOptions.None, fs)

// C#

NTAccount user = new NTAccount("Administrator");

Page 13: Practice Questions for Exam 70 536

FileSystemAccessRule ar = new FileSystemAccessRule(user, FileSystemRights.FullControl, AccessControlType.Allow);

FileSecurity fs = new FileSecurity();

fs.AddAccessRule(ar);

System.IO.File.Create("log.txt", 1000, FileOptions.None, fs);

c) ' VB

WindowsIdentity user = WindowsIdentity.GetCurrent()

Dim ar As FileSystemAccessRule = New FileSystemAccessRule(user, FileSystemRights.FullControl, AccessControlType.Allow)

Dim fs As FileSecurity = New FileSecurity

fs.AddAccessRule(ar)

System.IO.File.Create("log.txt", 1000, FileOptions.None, fs)

// C#

WindowsIdentity user = WindowsIdentity.GetCurrent();

FileSystemAccessRule ar = new FileSystemAccessRule(user, FileSystemRights.FullControl, AccessControlType.Allow);

FileSecurity fs = new FileSecurity();

fs.AddAccessRule(ar);

System.IO.File.Create("log.txt", 1000, FileOptions.None, fs);

d) ' VB

WindowsIdentity user = WindowsIdentity.GetCurrent()

Dim ar As FileSystemAccessRule = New FileSystemAccessRule(user, FileSystemRights.FullControl, AccessControlType.Deny)

Dim fs As FileSecurity = New FileSecurity

fs.AddAccessRule(ar)

System.IO.File.Create("log.txt", 1000, FileOptions.None, fs)

// C#

WindowsIdentity user = WindowsIdentity.GetCurrent();

FileSystemAccessRule ar = new FileSystemAccessRule(user, FileSystemRights.FullControl, AccessControlType.Deny);

FileSecurity fs = new FileSecurity();

fs.AddAccessRule(ar);

System.IO.File.Create("log.txt", 1000, FileOptions.None, fs);

Answer 3a) ' VB

Page 14: Practice Questions for Exam 70 536

Dim user As NTAccount = New NTAccount("Administrators")

Dim ar As FileSystemAccessRule = New FileSystemAccessRule(user, FileSystemRights.FullControl, AccessControlType.Allow)

Dim fs As FileSecurity = New FileSecurity

fs.AddAccessRule(ar)

System.IO.File.Create("log.txt", 1000, FileOptions.None, fs)

// C#

NTAccount user = new NTAccount("Administrators");

FileSystemAccessRule ar = new FileSystemAccessRule(user, FileSystemRights.FullControl, AccessControlType.Allow);

FileSecurity fs = new FileSecurity();

fs.AddAccessRule(ar);

System.IO.File.Create("log.txt", 1000, FileOptions.None, fs);

Question 4You are writing an application that connects to a network resource using SslStream. Which of the following types of exceptions should you catch so that you can retry authentication with a different set of credentials if authentication fails?

a) FatalAuthenticationExceptionb) Exceptionc) InvalidCredentialExceptiond) AuthenticationException

Answer 4d) AuthenticationException

For a thorough explanation of the questions and answers shown here, as well as practice tests and a comprehensive study guide for exam 70-536, order the MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0—Application Development Foundation book from Microsoft Press.

Implementing Interoperability, Reflection, and Mailing Functionality in a .NET Framework ApplicationThis section contains four practice questions to help prepare you to implement interoperability, reflection, and mailing functionality in a .NET Framework application.

Question 1 Question 2 Question 3 Question 4

Page 15: Practice Questions for Exam 70 536

Question 1You are writing an application that needs to transmit e-mail messages through a standard SMTP server, and also perform other actions. To ensure administrators configure the application with the appropriate permissions, you want to declare the required permission. You do not want to affect the permissions that are granted to the assembly, however. Which of the following declarations accomplishes this most effectively?a) ' VB

<Assembly:SmtpPermission(SecurityAction.RequestOptional, Access:="Connect")>

// C#

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

b) ' VB

<Assembly:SmtpPermission(SecurityAction.RequestMinimum, Access:="Connect")>

// C#

[assembly:SmtpPermission(SecurityAction.RequestMinimum, Access="Connect")]

c) ' VB

<Assembly:SmtpPermission(SecurityAction.RequestMinimum, Access:="ConnectToUnrestrictedPort")>

// C#

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

d) ' VB

<Assembly:SmtpPermission(SecurityAction.RequestOptional, Access:="ConnectToUnrestrictedPort")>

// C#

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

Answer 1b) ' VB

<Assembly:SmtpPermission(SecurityAction.RequestMinimum, Access:="Connect")>

// C#

[assembly:SmtpPermission(SecurityAction.RequestMinimum, Access="Connect")]

Page 16: Practice Questions for Exam 70 536

Question 2As part of your assembly, you must call a COM .dll file. Using Microsoft Visual Studio 2005, what is the easiest way to generate an interop assembly and enable your assembly to access the dynamic-link library (DLL)?a) 1. Click the Project menu, and then click Add Reference.

2. Click the COM tab.3. Select the library in the Available References list, and then click OK.

b) 1. Click the Project menu, and then click Add Reference.2. Click the .NET tab.3. Select the library in the Available References list, and then click OK.

c) 1. Click the Project menu, and then click Add Component.2. Click Browse and select your DLL.3. Click OK.

d) 1. Using Win32 development tools, create a command-line wrapper for the COM .dll file.2. In your .NET Framework assembly, call the command-line wrapper.

Answer 2a) 1. Click the Project menu, and then click Add Reference.

2. Click the COM tab.3. Select the library in the Available References list, and then click OK.

Question 3Which of the following code samples correctly creates a managed definition for an unmanaged function in the User32.dll file?a) ' VB

Imports System.Runtime.InteropServices

Public Class Win32

<DllDeclare ("user32.dll", CharSet := CharSet.Auto)>_

Public Shared Function MessageBox (ByVal hWnd As Integer, _

ByVal txt As String, ByVal caption As String, _

ByVal Typ As Integer) As IntPtr

End Function

End Class

// C#

using System.Runtime.InteropServices;

[DllDeclare("user32.dll")]

public static extern IntPtr MessageBox(int hWnd, String text,

String caption, uint type);

b) ' VB

Page 17: Practice Questions for Exam 70 536

Imports System.Runtime.InteropServices

Public Class Win32

<DllImport ("user32.dll", CharSet := CharSet.Auto)>_

Public Shared Function MessageBox (ByVal hWnd As Integer, _

ByVal txt As String, ByVal caption As String, _

ByVal Typ As Integer) As IntPtr

End Function

End Class

// C#

using System.Runtime.InteropServices;

[DllImport("user32.dll")]

public static extern IntPtr MessageBox(int hWnd, String text,

String caption, uint type);

c) ' VB

Imports System.Runtime.InteropServices

Public Class Win32

<DllImport ("user32.dll", CharSet := CharSet.Auto)>_

Declare Public Shared Function MessageBox (ByVal hWnd As Integer, _

ByVal txt As String, ByVal caption As String, _

ByVal Typ As Integer) As IntPtr

End Function

End Class

// C#

using System.Runtime.InteropServices;

[DllImport("user32.dll")]

declare public static extern IntPtr MessageBox(int hWnd, String text,

String caption, uint type);

d) ' VB

Imports System.Runtime.InteropServices

Public Class Win32

<DllDeclare ("user32.dll", CharSet := CharSet.Auto)>_

Declare Public Shared Function MessageBox (ByVal hWnd As Integer, _

ByVal txt As String, ByVal caption As String, _

Page 18: Practice Questions for Exam 70 536

ByVal Typ As Integer) As IntPtr

End Function

End Class

// C#

using System.Runtime.InteropServices;

[DllDeclare("user32.dll")]

declare public static extern IntPtr MessageBox(int hWnd, String text,

String caption, uint type);

Answer 3b) ' VB

Imports System.Runtime.InteropServices

Public Class Win32

<DllImport ("user32.dll", CharSet := CharSet.Auto)>_

Public Shared Function MessageBox (ByVal hWnd As Integer, _

ByVal txt As String, ByVal caption As String, _

ByVal Typ As Integer) As IntPtr

End Function

End Class

// C#

using System.Runtime.InteropServices;

[DllImport("user32.dll")]

public static extern IntPtr MessageBox(int hWnd, String text,

String caption, uint type);

Question 4Within your .NET Framework version 2.0 assembly, you need to load a .NET Framework version 1.1 assembly to examine its metadata given its file name. Which method should you use?

a) Assembly.LoadModuleb) Assembly.ReflectionOnlyLoadFromc) Assembly.ReflectionOnlyLoadd) Assembly.LoadFile

Answer 4b) Assembly.ReflectionOnlyLoadFrom

Page 19: Practice Questions for Exam 70 536

For a thorough explanation of the questions and answers shown here, as well as practice tests and a comprehensive study guide for exam 70-536, order the MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0—Application Development Foundation book from Microsoft Press.

Implementing Globalization, Drawing, and Text Manipulation Functionality in a .NET Framework ApplicationThis section contains three practice questions to help prepare you to implement globalization, drawing, and text manipulation functionality in a .NET Framework application.

Question 1 Question 2 Question 3

Question 1Which of the following code samples draws a line from the upper-left corner toward the lower-right corner?a) ' VB

Dim g As Graphics = Me.CreateGraphics

Dim p As Pen = New Pen(Color.Red, 7)

g.DrawLine(p, 1, 1, 100, 100)

// C#

Graphics g = this.CreateGraphics();

Pen p = new Pen(Color.Red, 7);

g.DrawLine(p, 1, 1, 100, 100);

b) ' VB

Dim g As Graphics = Me.CreateGraphics

Dim b As Brush = New Brush(Color.Red, 7)

g.DrawLine(b, 1, 1, 100, 100)

// C#

Graphics g = this.CreateGraphics();

Brush b = new Brush(Color.Red, 7);

g.DrawLine(b, 1, 1, 100, 100);

c) ' VB

Dim g As Graphics = Me.CreateGraphics

Dim p As Pen = New Pen(Color.Red, 7)

g.DrawLine(p, 100, 1, 1, 100)

Page 20: Practice Questions for Exam 70 536

// C#

Graphics g = this.CreateGraphics();

Pen p = new Pen(Color.Red, 7);

g.DrawLine(p, 100, 1, 1, 100);

d) ' VB

Dim g As Graphics = Me.CreateGraphics

Dim b As Brush = New Brush(Color.Red, 7)

g.DrawLine(b, 100, 1, 1, 100)

// C#

Graphics g = this.CreateGraphics();

Brush b = new Brush(Color.Red, 7);

g.DrawLine(b, 100, 1, 1, 100);

Answer 1a) ' VB

Dim g As Graphics = Me.CreateGraphics

Dim p As Pen = New Pen(Color.Red, 7)

g.DrawLine(p, 1, 1, 100, 100)

// C#

Graphics g = this.CreateGraphics();

Pen p = new Pen(Color.Red, 7);

g.DrawLine(p, 1, 1, 100, 100);

Question 2Which of the following code samples is the most efficient and compiles correctly?a) ' VB

Dim s As String = Nothing

Dim sb As StringBuilder = Nothing

sb = "Hello"

sb += ", "

sb += "World"

sb += "!"

s = sb.ToString

Page 21: Practice Questions for Exam 70 536

// C#

string s = null;

StringBuilder sb = null;

sb = "Hello";

sb += ", ";

sb += "World";

sb += "!";

s = sb.ToString();

b) ' VB

Dim s As String = Nothing

Dim sb As StringBuilder = Nothing

sb.Append("Hello")

sb.Append(", ")

sb.Append("World")

sb.Append("!")

s = sb.ToString

// C#

string s = null;

StringBuilder sb = null;

sb.Append("Hello");

sb.Append(", ");

sb.Append("World");

sb.Append("!");

s = sb.ToString();

c) ' VB

Dim s As String = Nothing

s = "Hello"

s += ", "

s += "World"

s += "!"

// C#

string s = null;

Page 22: Practice Questions for Exam 70 536

s = "Hello";

s += ", ";

s += "World";

s += "!";

d) ' VB

Dim s As String = Nothing

s = "Hello"

s = s + ", "

s = s + "World"

s = s + "!"

// C#

string s = null;

s = "Hello";

s += ", ";

s += "World";

s += "!";

Answer 2b) ' VB

Dim s As String = Nothing

Dim sb As StringBuilder = Nothing

sb.Append("Hello")

sb.Append(", ")

sb.Append("World")

sb.Append("!")

s = sb.ToString

// C#

string s = null;

StringBuilder sb = null;

sb.Append("Hello");

sb.Append(", ");

sb.Append("World");

sb.Append("!");

s = sb.ToString();

Page 23: Practice Questions for Exam 70 536

Question 3You are writing an English-language client application that must process data files that are 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 application to ensure that the data file is processed correctly?a) ' VB

CultureInfo.CurrentCulture = "sv-SE"

// C#

CultureInfo.CurrentCulture = "sv-SE";

b) ' VB

Thread.CurrentThread.CurrentCulture = New CultureInfo("sv-SE")

// C#

Thread.CurrentThread.CurrentCulture = new CultureInfo("sv-SE");

c) ' VB

CultureInfo.CurrentCulture = New CultureInfo("sv-SE")

// C#

CultureInfo.CurrentCulture = new CultureInfo("sv-SE");

d) ' VB

Thread.CurrentThread.CurrentCulture.Name = "sv-SE"

// C#

Thread.CurrentThread.CurrentCulture.Name = "sv-SE";

Answer 3b) ' VB

Thread.CurrentThread.CurrentCulture = New CultureInfo("sv-SE")

// C#

Thread.CurrentThread.CurrentCulture = new CultureInfo("sv-SE");

For a thorough explanation of the questions and answers shown here, as well as practice tests and a comprehensive study guide for exam 70-536, order the MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0—Application Development Foundation book from Microsoft Press.