Sunday, August 23, 2009

70-536 MCTS .NET Sample Questions #24

 

Hey Now,

Please feel free to check out my MCTS 70-536 reference page on Chris Catto.com. It’s a page with a summary of all of my posts.
As I study for this test I thought this would be good to post on to learn the content & others would be able to view & comment on it.

This content below is from some practice questions from the internet & not sure the answers are correct. There were over 200 questions & some duplicates, I hope to study all of them. I’ve also added some of my notes to these so any line starting with K8 (my nickname, first syllable of Catt o ) are my comments.

Thx,

Catto

Q#60 – Q#79

Question: 60

You are creating a strong-named assembly named Company1 that will be used in multiple applications. Company1 will be rebuilt frequently during the development cycle. You need to ensure that each time the assembly is rebuilt it works correctly with each application that uses it. You need to configure the computer on which you develop Company1 such that each application uses the latest build of Company1. Which two actions should you perform? (Each correct answer presents part of the solution. Choose two.)

A. Create a DEVPATH environment variable that points to the build output directory for the strong-named assembly.

B. Add the following XML element to the machine configuration file:

<developmentMode developerInstallation="true"/>

C. Add the following XML element to the machine configuration file:

<dependentAssembly>

<assemblyIdentity name="Company1"

publicKeyToken="32ab4ba45e0a69a1"

language="en-US" version="*.*.*.*" />

<publisherPolicy apply="no" />

</dependentAssembly>

D. Add the following XML element to the configuration file of each application that uses the

strong-named assembly:

<supportedRuntime version="*.*.*.*" />

E. Add the following XML element to the configuration file of each application that uses the

strong-named assembly:

<dependentAssembly>

<assemblyIdentity name="Company1"

publicKeyToken="32ab4ba45e0a69a1"

language="en-US" version="*.*.*.*" />

<bindingRedirect newVersion="*.*.*.*"/>

</dependentAssembly>

Answer: A, B

K8 – developerInstallation = true & create a devpath to point to build.

Question: 61

You are creating a class to compare a specially-formatted string. The default collation comparisons do not apply. You need to implement the IComparable<string> interface. Which code segment should you use?

A. public ref class Person : public IComparable<String^>{

public : virtual Int32 CompareTo(String^ other){

}}

B. public ref class Person : public IComparable<String^>{

public : virtual Int32 CompareTo(Object^ other){

}}

C. public ref class Person : public IComparable<String^>{

public : virtual Boolean CompareTo(String^ other){

}}

D. public ref class Person : public IComparable<String^>{

public : virtual Boolean CompareTo(Object^ other){

}}

Answer: A

K8 – use Int32 & CompareTo String

Question: 62

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

A. Dim objAlgo As HashAlgorithm = HashAlgorithm.Create("MD5")

Dim hash() As Byte = objAlgo.ComputeHash(message)

B. Dim objAlgo As HashAlgorithm = HashAlgorithm.Create("MD5")
Dim hash() As Byte = BitConverter.GetBytes(objAlgo.GetHashCode)

C. Dim objAlgo As HashAlgorithmobjAlgo =

HashAlgorithm.Create(message.ToString)
Dim hash() As Byte = objAlgo.Hash

D. Dim objAlgo As HashAlgorithm = HashAlgorithm.Create("MD5")
Dim hash() As

ByteobjAlgo.TransformBlock(message, 0, message.Length, hash, 0)

Answer: A

K8 – toss c out & ComputeHash is important method too.

Question: 63

You write the following custom exception class named CustomException.

Public Class CustomException

Inherits ApplicationException

Public Shared COR_E_ARGUMENT As Int32 = &H80070057

Public Sub New(ByVal strMessage As String)

MyBase.New(strMessage)

HResult = COR_E_ARGUMENT

End SubEnd Class

You need to write a code segment that will use the CustomException class to immediately return control to the COM caller. You also need to ensure that the caller has access to the error code. Which code segment should you use?

A. Return Marshal.GetExceptionForHR( _

CustomException.COR_E_ARGUMENT)

B. Return CustomException.COR_E_ARGUMENT

C. Marshal.ThrowExceptionForHR( _

CustomException.COR_E_ARGUMENT)

D. Throw New CustomException("Argument is out of bounds")

Answer: D

K8 Throw an exeption so the control will go to the COM

Question: 64

You need to return the contents of an isolated storage file as a string. The file is machine-scoped and is named Settings.dat. Which code segment should you use?

A. IsolatedStorageFileStream^ isoStream;isoStream = gcnew IsolatedStorageFileStream(

“Settings.dat”, FileMode::Open); String^ result = (gcnew StreamReader(isoStream))-

>ReadToEnd();

B. IsolatedStorageFile^ isoFile;

isoFile = IsolatedStorageFile::GetMachineStoreForAssembly();

IsolatedStorageFileStream^ isoStream;isoStream = gcnew IsolatedStorageFileStream(

“Settings.dat”, FileMode::Open, isoFile); String^ result = (gcnew StreamReader(isoStream))-

>ReadToEnd();

C. IsolatedStorageFileStream^ isoStream;isoStream = gcnew IsolatedStorageFileStream(

“Settings.dat”, FileMode::Open);String^ result = isoStream->ToString();

D. IsolatedStorageFile^ isoFile;isoFile = IsolatedStorageFile::GetMachineStoreForAssemblly();

IsolatedStorageFileStream^ isoStream;isoStream = gcnew IsolatedStorageFileStream(

“Settings.dat”, FileMode::Open, isoFile); String^ result = isoStream->ToString();

Answer: B

Question: 65

You are developing a fiscal report for a customer. Your customer has a main office in the United States and a satellite office in Mexico. You need to ensure that when users in the satellite office generate the report, the current date is displayed in Mexican Spanish format. Which code segment should you use?

A. Dim DTFormat As DateTimeFormatInfo = _

New CultureInfo("es-MX", False).DateTimeFormat

Dim DT As New DateTime( _

DateTime.Today.Year, DateTime.Today.Month, DateTime.Today.Day)Dim strDate As

String = _

DT.ToString(DTFormat.LongDatePattern)

B. Dim objCalendar As Calendar = _

New CultureInfo("es-MX", False).CalendarDim DT As New DateTime( _

DateTime.Today.Year, DateTime.Today.Month, DateTime.Today.Day)Dim strDate As

String = DT.ToString

C. Dim strDate As String = _

DateTimeFormatInfo.CurrentInfo.GetMonthName( _

DateTime.Today.Month)

D. Dim strDate As String = _

DateTime.Today.Month.ToString("es-MX")

Answer: A

K8 - DateTimeFormat

Question: 66

You are defining a class named CompanyClass that contains several child objects. CompanyClass contains a method named ProcessChildren that performs actions on the child objects. CompanyClass objects will be serializable. You need to ensure that the ProcessChildren method is executed after the CompanyClass object and all its child objects are reconstructed. Which two actions should you perform? (Each correct answer presents part of the solution. Choose two.)

A. Apply the OnDeserializing attribute to the ProcessChildren method.

B. Specify that CompanyClass implements the IDeserializationCallback interface.

C. Specify that CompanyClass inherits from the ObjectManager class.

D. Apply the OnSerialized attribute to the ProcessChildren method.

E. Create a GetObjectData method that calls ProcessChildren.

F. Create an OnDeserialization method that calls ProcessChildren.

Answer: B, F

K8 – Key words in question ‘executed after the class object’ OnDeserialization & IDeserializationCallback

Question: 67

You need to create a method to clear a Queue named q. Which code segment should you use?

A. for each (Object^ e in q) {

q.Dequeue();}

B. for each (Object^ e in q) {

q.Enqueue(0);}

C. q.Clear();

D. q.Dequeue();

Answer: C

K8 – I think 87 year old Granny could get this one right

Question: 71

You need to create a method to clear a Queue named q. Which code segment should you use?

A. Dim e As ObjectFor Each e In qq.Dequeue()Next

B. Dim e As ObjectFor Each e In qq.Enqueue(Nothing)Next

C. q.Clear()

D. q.Dequeue()

Answer: C

Question: 68

You need to write a code segment that transfers the first 80 bytes from a stream variable named stream1 into a new byte array named byteArray. You also need to ensure that the code segment assigns the number of bytes that are transferred to an integer variable named bytesTransferred. Which code segment should you use?

A. bytesTransferred = stream1->Read(byteArray, 0, 80);

B. for(int i = 0; i < 80; i++){

stream1->WriteByte(byteArray[i]);

bytesTransferred = i;

if (!stream1->CanWrite) {

break;

}}

C. while (bytesTransferred < 80) {

stream1->Seek(1, SeekOrigin::Current);

byteArray[bytesTransferred++] =

Convert::ToByte(stream1->ReadByte());}

D. stream1->Write(byteArray, 0, 80);bytesTransferred = byteArray->Length;

Answer: A

K8 – Read(byteArray, 0, 80); is the syntax

Question: 69

You are developing an application that dynamically loads assemblies from an application directory. You need to write a code segment that loads an assembly named Company1.dll into the current application domain. Which code segment should you use?

A. AppDomain domain = AppDomain.CurrentDomain;
string myPath = Path.Combine(domain.BaseDirectory,

“Company1.dll”);
Assembly asm = Assembly.LoadFrom(myPath);

B. AppDomain domain = AppDomain.CurrentDomain;
string myPath =

Path.Combine(domain.BaseDirectory, “Company1.dll”);
Assembly asm = Assembly.Load(myPath);

C. AppDomain domain = AppDomain.CurrentDomain;string myPath =

Path.Combine(domain.DynamicDirectory, “Company1.dll”);Assembly asm =

AppDomain.CurrentDomain.Load(myPath);

D. AppDomain domain = AppDomain.CurrentDomain;Assembly asm =

domain.GetData(“Company1.dll”);

Answer: A

K8 – Load From is important in this question

Question: 70

You are developing an application that will use custom authentication and role-based security. You need to write a code segment to make the runtime assign an unauthenticated principal object to each running thread. Which code segment should you use?

A. Dim objDomain As AppDomain =

AppDomain.CurrentDomainobjDomain.SetPrincipalPolicy( _

PrincipalPolicy.WindowsPrincipal)

B. Dim objDomain As AppDomain =

AppDomain.CurrentDomainobjDomain.SetThreadPrincipal(New

WindowsPrincipal(Nothing))

C. Dim objDomain As AppDomain =

AppDomain.CurrentDomainobjDomain.SetAppDomainPolicy( _

PolicyLevel.CreateAppDomainLevel())

D. Dim objDomain As AppDomain =

AppDomain.CurrentDomainobjDomain.SetPrincipalPolicy( _

PrincipalPolicy.UnauthenticatedPrincipal)

Answer: D

K8 – (PrincipalPolicy.UnauthenticatedPrincipal)

Question: 72

You develop a service application that needs to be deployed. Your network administrator creates a specific user account for your service application. You need to configure your service application to run in the context of this specific user account. What should you do?

A. Prior to installation, set the StartType property of the ServiceInstaller class.

B. Prior to installation, set the Account, Username, and Password properties of the ServiceProcessInstaller class.

C. Use the CONFIG option of the net.exe command-line tool to install the service.

D. Use the installutil.exe command-line tool to install the service.

Answer: B

K8 – ServiceProcessInstaller class when run app as user

Question: 73

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

A. Public Class Customer
Private m_AddressString As String
Public Sub New(ByVal Address As String)
m_AddressString = Address
End Sub

Public Function GetAddress() As String
Return m_AddressString
End FunctionEnd Class

B. Public Class Customer
Shared m_AddressString As String
Public Sub New()
End Sub
Public Shared Function GetAddress() As String
Return m_AddressString
End FunctionEnd Class

C. Public Class Customer
Private m_AddressString As String
Public Sub New()
End Sub
Public Function GetAddress() As String
Return m_AddressString
End FunctionEnd Class

D. Public Class Customer
Private m_AddressString As String
Public Sub New()
End Sub
Private Function GetAddress() As String
Return m_AddressString
End FunctionEnd Class

Answer: C

K8 – GetAddress should be Public

Question: 74

You are creating a new security policy for an application domain. You write the following lines of code.
Dim objPolicy As PolicyLevel = PolicyLevel.CreateAppDomainLevelDim

noTrustStatement As New PolicyStatement( _

objPolicy.GetNamedPermissionSet("Nothing"))

Dim fullTrustStatement As New PolicyStatement( _

objPolicy.GetNamedPermissionSet("FullTrust"))

You need to arrange code groups for the policy so that loaded assemblies default to the Nothing permission set. If the assembly originates from a trusted zone, the security policy must grant the assembly the FullTrust permission set. Which code segment should you use?

A. Dim objGroup1 As CodeGroup = New FirstMatchCodeGroup(
_ New ZoneMembershipCondition(SecurityZone.Trusted), _

fullTrustStatement)
Dim objGroup2 As CodeGroup = New UnionCodeGroup( _

New AllMembershipCondition, noTrustStatement)

B. Dim objGroup1 As CodeGroup = New FirstMatchCodeGroup( _ New AllMembershipCondition, noTrustStatement)
Dim objGroup2 As CodeGroup = New UnionCodeGroup( _

New ZoneMembershipCondition(SecurityZone.Trusted), _
fullTrustStatement)

C. Dim objGroup As CodeGroup = New UnionCodeGroup( _
New ZoneMembershipCondition(SecurityZone.Trusted), _
fullTrustStatement)

D. Dim objGroup As CodeGroup = New FirstMatchCodeGroup( _
New ZoneMembershipCondition(SecurityZone.Trusted), _
fullTrustStatement)

Answer: B

K8 – AllMembershipCondition & SecurityZone.Trusted

Question: 75

You are loading a new assembly into an application. You need to override the default evidence for the assembly. You require the common language runtime (CLR) to grant the assembly a

permission set, as if the assembly were loaded from the local intranet zone. You need to build the evidence collection. Which code segment should you use?

A. Evidence^ evidence = gcnew

Evidence(Assembly::GetExecutingAssembly()->Evidence);

B. Evidence^ evidence = gcnew Evidence();
evidence->AddAssembly(gcnew Zone(SecurityZone::Intranet));

C. Evidence^ evidence = gcnew Evidence();
evidence->AddHost(gcnew Zone(SecurityZone::Intranet));

D. Evidence^ evidence = gcnew Evidence(AppDomain::CurrentDomain->Evidence);

Answer: C

K8 – Question states internet security zone SecurityZone::Intranet

Question: 76

You need to read the entire contents of a file named Message.txt into a single string variable. Which code segment should you use?

A. string result = null;StreamReader reader = new StreamReader(“Message.txt”);result =

reader.Read().ToString();

B. string result = null;
StreamReader reader = new StreamReader(“Message.txt”);
result = reader.ReadToEnd();

C. string result = string.Empty;StreamReader reader = new StreamReader(“Message.txt”);
while

(!reader.EndOfStream) {

result += reader.ToString();}

D. string result = null;StreamReader reader = new StreamReader(“Message.txt”);result =

reader.ReadLine();

Answer: B

K8 – ReadToEnd works to read the entire file. Toss D out readline won’t get entire file

Question: 77

You need to generate a report that lists language codes and region codes. Which code segment should you use?

A. For Each objCulture As CultureInfo In

_CultureInfo.GetCultures(CultureTypes .SpecificCultures)

...Next

B. Dim objCulture As New CultureInfo("")Dim objTypes As CultureTypes = objCulture.CultureTypes ...

C. For Each objCulture As CultureInfo In

_CultureInfo.GetCultures(CultureTypes.NeutralCultures)

...Next

D. For Each objCulture As CultureInfo In

_CultureInfo.GetCultures(CultureTypes.ReplacementCultures)

...Next

Answer: A

K8 – SpecificCultures is needed & loop till we get them all.

Question: 78

You are developing a class library that will open the network socket connections to computers on the network. You will deploy the class library to the global assembly cache and grant it full trust. You write the following code to ensure usage of the socket connections.

Dim objPermission As SocketPermission = New

_SocketPermission(System.Security.Permissions.PermissionState.Unrestricted)objPermission.As

sert()

Some of the applications that use the class library might not have the necessary

permissions to open the network socket connections.

You need to cancel the assertion.

Which code segment should you use?

A. CodeAccessPermission.RevertAssert()

B. CodeAccessPermission.RevertDeny()

C. objPermission.Deny()

D. objPermission.PermitOnly()

Answer: A

K8 – Cancel the assertion – doesn’t RevertAssert() fit like a glove?

Question: 79

You are writing an application that uses SOAP to exchange data with other applications. You use a Department class that inherits from ArrayList to send objects to another application.
The Department object is named dept. You need to ensure that the application serializes the Department object for transport by using SOAP. Which code should you use?

A. Dim formatter As New SoapFormatter()Dim buffer As Byte() = New

Byte(dept.Capacity) {}Dim myStream As New MemoryStream(buffer) Dim o As

ObjectFor Each o In dept

formatter.Serialize(myStream, o)Next

B. Dim formatter As New SoapFormatter()
Dim buffer As Byte() = New Byte(dept.Capacity)Dim myStream As New

MemoryStream(buffer)formatter.Serialize(myStream, dept)

C. Dim formatter As New SoapFormatter()Dim myStream As New MemoryStream()Dim

o as ObjectFor Each o In dept

formatter.Serialize(myStream, o)Next

D. Dim formatter As New SoapFormatter()
Dim myStream As New

MemoryStream()formatter.Serialize(myStream, dept)

Answer: D

K8 – for the serialize the object name dept is needed.

No comments: