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. 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,
Q#33 – Q#50
Question: 33
You are developing an application that receives events asynchronously. You create a WqlEventQuery instance to specify the events and event conditions to which the application must respond. You also create a ManagementEventWatcher instance to subscribe to events matching the query. You need to identify the other actions you must perform before the application can receive events asynchronously. Which two actions should you perform? (Each correct answer presents part of the solution. Choose two.)
A. Start listening for events by calling the Start method of the ManagementEventWatcher.
B. Set up a listener for events by using the EventArrived event of the ManagementEventWatcher.
C. Use the WaitForNextEvent method of the ManagementEventWatcher to wait for the events.
D. Create an event handler class that has a method that receives an ObjectReadyEventArgs
parameter.
E. Set up a listener for events by using the Stopped event of the ManagementEventWatcher.
Answer: A, B
K8 – Start & EventArrived of ManagementEventWatcher
Question: 34
You need to write a code segment that transfers the contents of a byte array named dataToSend by using a NetworkStream object named netStream. You need to use a cache of size 8,192
bytes. Which code segment should you use?
A. MemoryStream^ memStream = gcnew
MemoryStream(8192);memStream->Write(dataToSend, 0, (int) netStream->Length);
B. MemoryStream^ memStream = gcnew
MemoryStream(8192);netStream->Write(dataToSend, 0, (int) memStream->Length);
C. BufferedStream^ bufStream =
gcnew BufferedStream(netStream, 8192);bufStream->Write(dataToSend, 0, dataToSend- >Length);
D. BufferedStream^ bufStream =
gcnew BufferedStream(netStream);bufStream->Write(dataToSend, 0, 8192);
Answer: C
K8 – BufferedStream not Memory Stream C is correct Syntax
Question: 35
You are writing a method to compress an array of bytes. The array is passed to the method in a parameter named document. You need to compress the incoming array of bytes and return the result as an array of bytes. Which code segment should you use?
A. MemoryStream strm = new MemoryStream(document);
B. DeflateStream deflate = new DeflateStream(strm,
CompressionMode.Compress); byte[] result = new byte[document.Length];deflate.Write(result,
0, result.Length); return result;
B. MemoryStream strm = new MemoryStream(document);
DeflateStream deflate = new
DeflateStream(strm,
CompressionMode.Comress);deflate.Write(docemtn, 0,
document.Length);deflate.Close();return strm.ToArray();
C. MemoryStream strm = new MemoryStream();
DeflateStream deflate = new
DeflateStream(strm, CompressionMode.Compress);deflate.Write(decument, 0,
decument.Length);deflate.Close();return strm.ToArray();
D. MemoryStream inStream = new MemoryStream(document);
DeflateStream deflate =
new DeflateStream(inStream, CompressionMode.Compress); MemoryStream outStream =
new MemoryStream();int b;while ((b = deflate.ReadByte()) ! = -1) {
outStream.WriteByte((byte)b);} return outStream.ToArray();
Answer: C
K8 - MemoryStream();
Question: 36
You need to select a class that is optimized for key-based item retrieval from both small and large collections. Which class should you choose?
A. OrderedDictionary class
B. HybridDictionary class
C. ListDictionary class
D. Hashtable class
Answer: B
K8 – Key Based Items Large & small collections HybridDictionary Class.
Question: 37
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. SoapFormatter formatter = new SoapFormatter();byte[] buffer = new
byte[dept.Capacity];MemoryStream stream = new MemoryStream(buffer);
foreach
(object o in dept) {
formatter.Serialize(stream, o);}
B. SoapFormatter formatter = new SoapFormatter();byte[] buffer = new
byte[dept.Capacity];MemoryStream stream = new MemoryStream(buffer);
formatter.Serialize(stream, dept);
C. SoapFormatter formatter = new SoapFormatter();MemoryStream stream = new
MemoryStream();
foreach (object o in dept) {
Formatter.Serialize(stream, o);}
D. SoapFormatter formatter = new SoapFormatter();
MemoryStream stream = new
MemoryStream(); formatter.Serialize(stream, dept);
Answer: D
K8 Need MemorySteam & dept / class name in the Serialize parameters.
Question: 38
You create a class library that contains the class hierarchy defined in the following code segment. (Line numbers are included for reference only.)
01. public ref class Employee {
02.03. public : 04.
String^ Name;05. };06.07. public ref class Manager : public Employee {08.09.
public :10.
int Level;11. };12.13. public ref class Group {
14.15. public : 16. array<Employee^>^
Employees;17. };
You create an instance of the Group class. You populate the fields of the instance. When you attempt to serialize the instance by using the Serialize method of the XmlSerializer class, you receive InvalidOperationException. You also receive the following error message: "There was an error generating the XML document." You need to modify the code segment so that you can successfully serialize instances of the Group class by using the XmlSerializer class. You also need to ensure that the XML output contains an element for all public fields in the class hierarchy. What should you do?
A. Insert the following code between lines 14 and 15 of the code segment:
[XmlArrayItem(Type = __typeof(Employee))]
[XmlArrayItem(Type = __typeof(Manager))]
B. Insert the following code between lines 14 and 15 of the code segment:
[XmlElement(Type = __typeof(Employees))]
C. Insert the following code between lines 14 and 15 of the code segment:
[XmlArray(ElementName="Employees")]
D. Insert the following code between lines 3 and 4 of the code segment:
[XmlElement(Type = __typeof(Employee))]
andInsert the following code segment between lines 8 and 9 of the code segment:
[XmlElement(Type = __typeof(Manager))]
Answer: A
K8 XmlArrayItem
Question: 39
You need to write a code segment that performs the following tasks:
Retrieves the name of each paused service.
Passes the name to the Add method of Collection1. Which code segment should you use?
A. Dim searcher As ManagementObjectSearcher = _New ManagementObjectSearcher( _
"Select * from Win32_Service where State = 'Paused'")For Each svc As
ManagementObject In searcher.Get()
Collection1.Add(svc("DisplayName"))Next
B. Dim searcher As ManagementObjectSearcher = _New ManagementObjectSearcher ( _
"Select * from Win32_Service", "State = 'Paused'")For Each svc As ManagementObject
In searcher.Get()
Collection1.Add(svc("DisplayName"))Next
C. Dim searcher As ManagementObjectSearcher = _ New ManagementObjectSearcher( _
"Select * from Win32_Service")For Each svc As ManagementObject In searcher.Get()
If svc("State").ToString() = "'Paused'" Then
Collection1.Add(svc("DisplayName"))
End IfNext
D. Dim searcher As New ManagementObjectSearcher()searcher.Scope = New
ManagementScope("Win32_Service")For Each svc As ManagementObject In
searcher.Get()
If svc("State").ToString() = "Paused" Then
Collection1.Add(svc("DisplayName"))
End IfNext
Answer: A
K8 need the where clause to select all the ‘paused’
Question: 40
You are writing a method that accepts a string parameter named message. Your method must break the message parameter into individual lines of text and pass each line to a second method named Process. Which code segment should you use?
A. Dim reader As New
StringReader(message)ProcessMessage(reader.ReadToEnd())reader.Close()
B. Dim reader As New StringReader(message)
While reader.Peek() <> -1
Dim line as String = reader.Read().ToString()
ProcessMessage(line)End Whilereader.Close()
C. Dim reader As New
StringReader(message)ProcessMessage(reader.ToString())reader.Close()
D. Dim reader As New StringReader(message)While reader.Peek() <> -1
ProcessMessage(reader.ReadLine())End Whilereader.Close()
Answer: D
K8 – Need the reader.Peek to find the blank space to break & reader.ReadLine() Looks like A & C can be tossed out.
Question: 41
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 {
string addressString;
public Customer(string address) { addressString = address; }
public string GetAddress() { return addressString; }}
B. public class Customer {
static string addressString;
public Customer() { }
public static string GetAddress() { return addressString; }}
C. public class Customer {
string addressString;
public Customer() { }
public string GetAddress() { return addressString; }}
D. public class Customer {
string addressString;
public Customer() { }
internal string GetAddress() { return addressString; }}
Answer: C
K8 – B can be tossed out with static String adressString; D can be out with the syntax internal string
Question: 42
You are creating a class that performs complex financial calculations. The class contains a method named GetCurrentRate that retrieves the current interest rate and a variable named currRate that stores the current interest rate. You write serialized representations of the class. You need to write a code segment that updates the currRate variable with the current interest rate when an instance of the class is deserialized. Which code segment should you use?
A. [OnSerializing]void UpdateValue (StreamingContext^ context) {
currRate = GetCurrentRate();}
B. [OnSerializing]void UpdateValue(SerializationInfo^ info) {
info->AddValue(“currentRate”, GetCurrentRate());}
C. [OnDeserializing]void UpdateValue(SerializationInfo^ info) {
info->AddValue(“currentRate”, GetCurrentRate());}
D. [OnDeserialized]void UpdateValue(StreamingContext^ context) { currRate = GetCurrentRate();}
Answer: D
K8 – in question states when an instance of the class is deserialized. Therefore we use OnDeserialized.
Question: 43
You are developing a class library. Portions of your code need to access system environment variables. You need to force a runtime SecurityException only when callers that are higher in the call stack do not have the necessary permissions. Which call method should you use?
A. set.Demand();
B. set.Assert();
C. set.PermitOnly();
D. set.Deny();
Answer: A
K8 Demand first thought was deny
Question: 44
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. CultureInfo^ culture = gcnew CultureInfo(“es-MX”, false);DateTimeFormatInfo^ dtfi = culture-
>DateTimeFormat;DateTime^ dt = gcnew DateTime(DateTime::Today::Year,
DateTime::Today::Month, DateTime::Today::Day);String^ dateString = dt->ToString(dtfi-
>LongDatePattern);
B. Calendar^ cal = gcnew CultureInfo(“es-MX”, false)::Calendar; DateTime^dt = gcnew
DateTime(DateTime::Today::Year, DateTime::Today::Month, DateTime::Today::Day);
String^dateString = dt-> ToString();
C. String^ dateString =
DateTimeFormatInfo::CurrentInfo::GetMonthName(DateTime::Today::Month);
D. String^ dateString = DateTime::Today::Month::ToString(“es-MX”);
Answer: A
K8 – need cultureinfo right
Question: 45
You create an application that stores information about your customers who reside in various regions. You are developing internal utilities for this application. You need to gather regional information about your customers in Canada. Which code segment should you use?
A. for each (CultureInfo^ culture in
CultureInfo::GetCultures(CultureTypes::SpecificCultures)) {
// Output the region information...}
B. CultureInfo^ cultureInfo = gcnew CultureInfo(“CA”);
// Output the region information...
C. RegionInfo^ regionInfo = gcnew RegionInfo(“CA
// Output the region information...
D. RegionInfo^ regionInfo = gcnew RegionInfo(“”);if(regionInfo->Name == “CA”){
// Output the region information...}
Answer: C
K8 Region is more specific & is needed for CA nada
Question: 46
You need to generate a report that lists language codes and region codes. Which code segment should you use?
A. for each (CultureInfo^ culture in
CultureInfo::GetCultures(CultureTypes::SpecificCultures)) {
// Output the culture information...}
B. CultureInfo^ culture = gcnew CultureInfo(“”); CultureTypes^ types = culture->CultureTypes;
// Output the culture information...
C. for each (CultureInfo^ culture in
CultureInfo::GetCultures(CultureTypes::NeutralCultures)) {
// Output the culture information...}
D. for each (CultureInfo^ culture in
CultureInfo::GetCultures(CultureTypes::ReplacementCultures)) {
// Output the culture information...}
Answer: A
K8 – just reading answers B can be tossed out since no loop; CultureTypes::SpecificCultures is needed
Question: 47
You are developing a method to hash data with the Secure Hash 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 SHA1. You also need to place the result into a byte array named hash. Which code segment should you use?
A. SHA1 sha = new SHA1CryptoServiceProvider();byte[] hash =
null;sha.TransformBlock(message, 0, message.Length, hash, 0);
B. SHA1 sha = new SHA1CryptoServiceProvider();byte[] hash =
BitConverter.GetBytes(sha.GetHashCode());
C. SHA1 sha = new SHA1CryptoServiceProvider();byte[] hash = sha.ComputeHash(message);
D. SHA1 sha = new SHA1CryptoServiceProvider();sha.GetHashCode();byte[] hash = sha.Hash;
Answer: C
K8 - ComputeHash method
Question: 48
You are developing a method to hash data for later verification by using the MD5 algorithm. The data is passed to your method as a byte array named message. You need to compute the hash of the incoming parameter by using MD5. You also need to place the result into a byte array. Which code segment should you use?
A. HashAlgorithm algo = HashAlgorithm.Create(“MD5”);byte[] hash =
algo.ComputeHash(message);
B. HashAlgorithm algo = HashAlgorithm.Create(“MD5”);byte[] hash =
BitConverter.GetBytes(algo.GetHashCode());
C. HashAlgorithm algo;algo = HashAlgorithm.Create(message.ToString());byte[] hash =
algo.Hash;
D. HashAlgorithm algo = HashAlgorithm.Create(“MD5”);byte[] hash =
null;algo.TransformBlock(message, 0, message.Length, hash, 0);
Answer: A
K8 – SHA1 or MD5 the ComputeHash is need for the requirements asked in the question.
Question: 49
You create a method that runs by using the credentials of the end user. You need to use Microsoft Windows groups to authorize the user. You must add a code segment that identifies whether a user is in the local group named Clerk. Which code segment should you use?
A. Dim objUser As WindowsIdentity = WindowsIdentity.GetCurrentFor Each objGroup
As IdentityReference In objUser.Groups
Dim objNT As NTAccount = _
DirectCast(objGroup.Translate( _
Type.GetType("NTAccount")), NTAccount)
Dim blnAuth As Boolean = objNT.Value.Equals( _
Environment.MachineName & "\Clerk")
If blnAuth Then Exit ForNext
B. Dim objUser As WindowsPrincipal = _
DirectCast(Thread.CurrentPrincipal, WindowsPrincipal)Dim blnAuth As Boolean =
objUser.IsInRole("Clerk")
C. Dim objUser As GenericPrincipal = _
DirectCast(Thread.CurrentPrincipal, GenericPrincipal)Dim blnAuth As Boolean =
objUser.IsInRole("Clerk")
D. Dim objUser As WindowsPrincipal = _
DirectCast(Thread.CurrentPrincipal, WindowsPrincipal)Dim blnAuth As Boolean = _
objUser.IsInRole(Environment.MachineName)
Answer: B
K8 – IsInRole is needed & WindowsPrincipal
Question: 50
You write the following code to call a function from the Win32 Application Programming Interface (API) by using platform invoke. int rc = MessageBox(hWnd, text, caption, type); You need to define a method prototype. Which code segment should you use?
A. [DllImport("user32")]extern int MessageBox(int hWnd, String^ text, String^ caption, uint type);
B. [DllImport("user32")]extern int MessageBoxA(int hWnd, String^ text, String^ caption, uint type);
C. [DllImport("user32")]extern int Win32API_User32_MessageBox(
Int hWnd, String^ text, String^ caption, uint type);
D. [DllImport("C:\\WINDOWS\\system32\\user32.dll")]extern int MessageBox(int
hWnd, String^ text,
String^ caption, uint type);
Answer: A
K8 - int rc = MessageBox(hWnd, text, caption, type); in questions in key info.
No comments:
Post a Comment