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.
I'm try to split a previous post Here is the second half.
Question: 198
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 Class Group
02 Public Employees As Employee()
03 End Class
0405 Public Class Employee
06 Public Name As String
07 End Class
0809 Public Class Manager
10 Inherits Employee
11 Public Level As Integer
12 End Class
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 1 and 2 of the code segment:
<XmlArrayItem(Type:=GetType(Employee))> _
<XmlArrayItem(Type:=GetType(Manager))> _
B. Insert the following code between lines 1 and 2 of the code segment:
<XmlElement(Type:=GetType(Employee))> _
C. Insert the following code between lines 1 and 2 of the code segment:
<XmlArray(ElementName:="Employees")> _
D. Insert the following code between lines 5 and 6 of the code segment:
<XmlElement(Type:=GetType(Employee))>
andInsert the following code between lines 10 and 11 of the code segment:
<XmlElement(Type:=GetType(Manager))>
Answer: A
K8 – XML Array Item
Question: 199
You are testing a method that examines a running process. This method returns an ArrayList containing the name and full path of all modules that are loaded by the process. You need to list the modules loaded by a process named C:\TestApps\Process1.exe. Which code segment should you use?
A. ArrayList ar = new ArrayList();
Process[] procs;
ProcessModuleCollection modules;
procs = Process.GetProcesses(@”Process1”);
if (procs.Length > 0) {modules = porcs[0].Modules;
foreach (ProcessModule mod in modules) {
ar.Add(mod.ModuleName);
}}
B. ArrayList ar = new ArrayList();
Process[] procs;
ProcessModuleCollection modules;
procs = Process.GetProcesses(@”C:\TestApps\Process1.exe”);
if (procs.Length > 0) {modules = porcs[0].Modules;
foreach (ProcessModule mod in modules) {
ar.Add(mod.ModuleName);
}}
C. ArrayList ar = new ArrayList();
Process[] procs;
ProcessModuleCollection modules;
procs = Process.GetProcessesByName(@”Process1”);
if (procs.Length > 0) {modules = porcs[0].Modules;
foreach (ProcessModule mod in modules) {
ar.Add(mod.FileName);
}}
D. ArrayList ar = new ArrayList();
Process[] procs;
ProcessModuleCollection modules;
procs =Process.GetProcessesByName(@”C:\TestApps\Process1.exe”);
if
(procs.Length > 0) {
modules = porcs[0].Modules;
foreach (ProcessModule mod in modules) {
ar.Add(mod.FileName);
}}
Answer: C
K8 – Q:List modules loaded by process A: GetProcessesByName
Question: 200
You write the following code to implement the CompanyClass.MyMethod function.
public class CompanyClass {
public int MyMethod(int arg) {
return arg;
}}
You need to call the CompanyClass.MyMethod function dynamically from an unrelated class in your assembly. Which code segment should you use?
A. CompanyClass myClass = new CompanyClass();
Type t = typeof(CompanyClass);
MethodInfo m = t.GetMethod(“MyMethod”);
int i = (int)m.Invoke(this, new object[] { 1 });
B. CompanyClass myClass = new CompanyClass();
Type t = typeof(CompanyClass); |
MethodInfo m = t.GetMethod(“MyMethod”);
int i = (int) m.Invoke(myClass, new object[] { 1 });
C. CompanyClass myClass = new CompanyClass();
Type t = typeof(CompanyClass);
MethodInfo m = t.GetMethod(“CompanyClass.MyMethod”);
int i = (int)m.Invoke(myClass, new object[] { 1 });
D. Type t = Type.GetType(“CompanyClass”);
MethodInfo m = t.GetMethod(“MyMethod”);
int i = (int)m.Invoke(this, new object[] { 1 });
Answer: B
K8 – MyClass
Question: 201
You need to create a dynamic assembly named MyAssembly. You also need to save the assembly to disk. Which code segment should you use?
A. Dim objAssembly As New AssemblyName()objAssembly.Name = "MyAssembly"
Dim objBuilder As AssemblyBuilder =
_AppDomain.CurrentDomain.DefineDynamicAssembly( _objAssembly,
AssemblyBuilderAccess.Run)objBuilder.Save("MyAssembly.dll")
B. Dim objAssembly As New AssemblyName()objAssembly.Name = "MyAssembly"
Dim objBuilder As AssemblyBuilder =
_AppDomain.CurrentDomain.DefineDynamicAssembly( _objAssembly,
AssemblyBuilderAccess.Save)objBuilder.Save("MyAssembly.dll")
C. Dim objAssembly As New AssemblyName()objAssembly.Name = "MyAssembly"
Dim objBuilder As AssemblyBuilder =
_AppDomain.CurrentDomain.DefineDynamicAssembly( _objAssembly,
AssemblyBuilderAccess.RunAndSave)objBuilder.Save("MyAssembly.dll")
D. Dim objAssembly As New AssemblyName()objAssembly.Name = "MyAssembly"
Dim objBuilder As AssemblyBuilder =
_AppDomain.CurrentDomain.DefineDynamicAssembly( _objAssembly,
AssemblyBuilderAccess.Save)objBuilder.Save("c:\MyAssembly.dll")
Answer: B
K8 – Q: Create & Save A: AssemblyBuilderAccess.Save “MyAssebly”
Question: 202
You write the following code.
Public Delegate Sub FaxDocs(ByVal sender As Object, _
ByVal args as FaxArgs)
You need to create an event that will invoke FaxDocs. Which code segment should you use?
A. Public Shared Event Fax As FaxDocs
B. Public Shared Event FaxDocs As FaxArgs
C. Public Class FaxArgs
Inherits EventArgs
Private coverPageInfo As String
Public Sub New(ByVal coverInfo As String)
Me.coverPageInfo = coverInfo
End Sub
Public ReadOnly Property CoverPageInformation As String
Get
Return Me.coverPageInfo
End Get
End PropertyEnd Class
D. Public Class FaxArgs
Inherits EventArgs
Private coverPageInfo As String
Public ReadOnly Property CoverPageInformation As String Get
Return Me.coverPageInfo
End Get
End PropertyEnd Class
Answer: A
K8 – Create an event to invoke FaxDocs A: Public Shared Event Fax As FaxDocs
Question: 203
You are developing a method to encrypt sensitive data with the Data Encryption Standard (DES) algorithm. Your method accepts the following parameters:
The byte array to be encrypted, which is named messageAn encryption key, which is named keyAn initialization vector, which is named iv You need to encrypt the data. You also need to write the encrypted data to a MemoryStream object. Which code segment should you use?
A. DES^ des = gcnew DESCryptoServiceProvider();
des->BlockSize = message->Length;
ICryptoTransform^ crypto = des->CreateEncryptor(key, iv);
MemoryStream ^cipherStream = gcnew MemoryStream();
CryptoStream ^cryptoStream = gcnew CryptoStream(cipherStream,crypto, CryptoStreamMode::Write);
cryptoStream->Write(message, 0, message->Length);
B. DES^ des = gcnew DESCryptoServiceProvider();
ICryptoTransform^ crypto = des->CreateDecryptor(key, iv);
MemoryStream ^cipherStream = gcnew MemoryStream();
CryptoStream ^cryptoStream = gcnew
CryptoStream(cipherStream, crypto,
CryptoStreamMode::Write);
cryptoStream->Write(message, 0, message->Length);
C. DES^ des = gcnew DESCryptoServiceProvider();
ICryptoTransform^ crypto = des->CreateDecryptor();
MemoryStream ^cipherStream = gcnew MemoryStream();CryptoStream ^cryptoStream
= gcnew CryptoStream(cipherStream,crypto,
CryptoStreamMode::Write);
cryptoStream->Write(message, 0, message->Length);
D. DES^ des = gcnew DESCryptoServiceProvider();
ICryptoTransform^ crypto = des->CreateEncryptor(key, iv);
MemoryStream ^cipherStream = gcnew MemoryStream();
CryptoStream ^cryptoStream = gcnew CryptoStream(cipherStream, crypto, CryptoStreamMode::Write);
cryptoStream->Write(message, 0, message->Length);
Answer: D
K8 – Q: Encrypt A: CreateEncryptor ICryptoTransform
Question: 204
You are testing a newly developed method named PersistToDB. This method accepts a parameter of type EventLogEntry. This method does not return a value. You need to create a code segment that helps you to test the method. The code segment must read entries from the application log of local computers and then pass the entries on to the PersistToDB method. The code block must pass only events of type Error or Warning from the source MySource to the PersistToDB method. Which code segment should you use?
A. Dim myLog As New EventLog("Application", ".")
For Each entry As EventLogEntry In myLog.Entries
If entry.Source = "MySource" Then
PersistToDB(entry)
End If
Next
B. Dim myLog as New EventLog("Application", ".")
myLog.Source = "MySource"
For Each entry As EventLogEntry In myLog.Entries
If entry.EntryType = (EventLogEntryType.Error And _
EventLogEntryType.Warning) Then
PersistToDB(entry)
End If
Next
C. Dim myLog as New EventLog("Application", ".")
For Each entry As EventLogEntry In myLog.Entries
If entry.Source = "MySource" Then
If (entry.EntryType = EventLogEntryType.Error) Or _
(entry.EntryType = EventLogEntryType.Warning) Then
PersistToDB(entry)
End If
End If
Next
D. Dim myLog as New EventLog("Application", ".")
myLog.Source = "MySource"
For Each entry As EventLogEntry In myLog.Entries
If (entry.EntryType = EventLogEntryType.Error) Or _
(entry.EntryType = EventLogEntryType.Warning) Then
PersistToDB(entry)
End If
Next
Answer: C
A: Loop threw all w/ some ifs to check if
Question: 205
You are creating an undo buffer that stores data modifications. You need to ensure that the undo functionality undoes the most recent data modifications first. You also need to ensure that the undo buffer permits the storage of strings only. Which code segment should you use?
A. Stack<String^> undoBuffer = gcnew Stack<String^>();
B. Stack undoBuffer = gcnew Stack();
C. Queue<String^> undoBuffer = gcnew Queue<String^>();
D. Queue undoBuffer = gcnew Queue();
Answer: A
K8 – Most rescent Stack LIFO A: Stack String
Question: 206
You need to write a multicast delegate that accepts a DateTime argument. Which code segment should you use?
A. public delegate int PowerDeviceOn(bool result,
DateTime autoPowerOff);
B. public delegate bool PowerDeviceOn(object sender,
EventsArgs autoPowerOff);
C. public delegate void PowerDeviceOn(DataTime autoPowerOff);
D. public delegate bool PowerDeviceOn(DataTime autoPowerOff);
Answer: C
K8 – void PowerDeviceOn DataTemautoPowerOff
Question: 207
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. Dim objStream As New MemoryStream(document)
Dim objDeflate As New DeflateStream(objStream, CompressionMode.Compress)
Dim result(document.Length) As Byteobj
Deflate.Write(result, 0, result.Length)
Return result
B. Dim objStream As New MemoryStream(document)
Dim objDeflate As New DeflateStream(objStream, CompressionMode.Compress)obj
Deflate.Write(document, 0, document.Length)obj
Deflate.Close()
Return objStream.ToArray
C. Dim objStream As New MemoryStream()
Dim objDeflate As New DeflateStream(objStream, CompressionMode.Compress)obj
Deflate.Write(document, 0, document.Length)obj
Deflate.Close()
Return objStream.ToArray
D. Dim objStream As New MemoryStream()
Dim objDeflate As New DeflateStream(objStream, CompressionMode.Compress)
Dim outStream As New MemoryStreamDim b As IntegerWhile (b = objDeflate.ReadByte)
outStream.WriteByte(CByte(b))
End
WhileReturn outStream.ToArray
Answer: C
K8 – MemoryStream()
Question: 208
You create the definition for a Vehicle class by using the following code segment.
public ref class Vehicle {
public : [XmlAttribute(AttributeName = "category")]
String^ vehicleType;
String^ model;
[XmlIgnore]
int year;
[XmlElement(ElementName = "mileage")]
int miles;
Condition Type condition;
Vehicle() {}
enum ConditionType {
[XmlEnum("Poor")] BelowAverage,
[XmlEnum("Good")] Average,
[XmlEnum("Excellent")] AboveAverage
}};
You create an instance of the Vehicle class. You populate the public fields of the Vehicle class instance as shown in the following table:
Exhibit:
You need to identify the XML block that is produced when this Vehicle class instance is serialized. Which block of XML represents the output of serializing the Vehicle instance?
A. <?xml version="1.0" encoding="utf-8"?>
<Vehicle
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema""
vehicleType="car">
<model>racer</model>
<miles>15000</miles>
<condition>AboveAverage</condition>
</Vehicle>
B. <?xml version="1.0" encoding="utf-8"?>
<Vehicle
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
category="car">
<model>racer</model>
<mileage>15000</mileage>
<condition>Excellent</condition>
</Vehicle>
C. <?xml version="1.0" encoding="utf-8"?>
<Vehicle
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
category="car">
<model>racer</model>
<mileage>15000</mileage>
<conditionType>Excellent</conditionType>
</Vehicle>
D. <?xml version="1.0" encoding="utf-8"?>
<Vehicle
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<category>car</category>
<model>racer</model>
<mileage>15000</mileage>
<condition>Excellent</condition>
</Vehicle>
Answer: B
K8 – Serilize XML
Question: 209
You are writing a method to compress an array of bytes. The bytes to be compressed are passed to the method in a parameter named document. You need to compress the contents of the incoming parameter. Which code segment should you use?
A. Dim inStream As New MemoryStream(document)
Dim zipStream As New GZipStream( _inStream, CompressionMode.Compress)
Dim result(document.Length) As
BytezipStream.Write(result, 0, result.Length)
Return result
B. Dim objStream As New MemoryStream(document)
Dim zipStream As New GZipStream( _ objStream, CompressionMode.Compress)zipStream.Write(document, 0,
document.Length)zipStream.Close()
Return objStream.ToArray
C. Dim outStream As New MemoryStream
Dim zipStream As New GZipStream( _outStream, CompressionMode.Compress)zipStream.Write(document, 0,
document.Length)zipStream.Close()
Return outStream.ToArray
D. Dim objStream As New MemoryStream(document)
Dim zipStream As New
GZipStream( _objStream, CompressionMode.Compress)
Dim outStream As New
MemoryStreamDim b As IntegerWhile (b =
zipStream.ReadByte)outStream.WriteByte(CByte(b))
End While
Return outStream.ToArray
Answer: C
K8 – Compress array of bytes
Question: 210
You are developing a method to decrypt data that was encrypted with the Triple DES Algorithm. The method accepts the following parameters: The byte array to be decrypted, which is named cipherMessageThe key, which is named key An initialization vector, which is named iv You need to decrypt the message by using the TripleDES class and place the result in a string. Which code segment should you use?
A. TripleDES des = new TripleDESCryptoServiceProvider();
des.BlockSize = cipherMessage.Length;
ICryptoTransform crypto = des.CreateDecryptor(key, iv);
MemoryStream cipherStream = new MemoryStream(cipherMessage);
CryptoStream cryptoStream = new CryptoStream( cipherStream, crypto, CryptoStreamMode.Read);
string message;
message = new StreamReader(cryptoStream).ReadToEnd();
B. TripleDES des = new TripleDESCryptoServiceProvider();
des.FeedbackSize = cipherMessage.Length;
ICryptoTransform crypto = des.CreateDecryptor(key, iv);
MemoryStream cipherStream = new MemoryStream(cipherMessage);
CryptoStream cryptoStream = new CryptoStream(
cipherStream, crypto, CryptoStreamMode.Read);
string message;
message = new StreamReader(cryptoStream).ReadToEnd();
C. TripleDES des = new TripleDESCryptoServiceProvider();
ICryptoTrans form crypto = des.CreateDecryptor();
MemoryStream cipherStream = new MemoryStream(cipherMessage);
CryptoStream cryptoStream = new CryptoStream(
cipherStream, crypto, CryptoStreamMode.Read);
string message;
message = new StreamReader(cryptoStream).ReadToEnd();
D. TripleDES des = new TripleDESCryptoServiceProvider();
ICryptoTrans form crypto = des.CreateDecryptor(key, iv);
MemoryStream cipherStream = new MemoryStream(cipherMessage);
CryptoStream cryptoStream = new CryptoStream( cipherStream, crypto, CryptoStreamMode.Read);
string message;
message = new StreamReader(cryptoStream).ReadToEnd();
Answer: D
K8 - Des.CreateDecryptor(key, iv)
Question: 211
You are developing a utility screen for a new client application. The utility screen displays a thermometer that conveys the current status of processes being carried out by the application. You need to draw a rectangle on the screen to serve as the background of the thermometer as shown in the exhibit. The rectangle must be filled with gradient shading. Which code segment should you choose?
A - Rectangle^ rectangle = gcnew Rectangle(10, 10, 450, 25); LinearGradientBrush^ rectangleBrush = gcnew LinearGradientBrush(rectangle, Color::AliceBlue,
Color::CornflowerBlue,LinearGradientMode::ForwardDiagonal);
Pen^ rectanglePen = gcnew Pen(rectangleBrush);
Graphics^ g = this->CreateGraphics();
g->DrawRectangle(rectanglePen, rectangle);
B - Rectangle^ rectangle = gcnew Rectangle(10, 10, 450, 25); LinearGradientBrush^ rectangleBrush = gcnew LinearGradientBrush(rectangle, Color::AliceBlue, Color::CornflowerBlue, LinearGradientMode::ForwardDiagonal);
Pen^ rectanglePen = gcnew Pen(rectangleBrush);
Graphics^ g = this->Createsraphics();
g->FillRectangle(rectangleBrush, rectangle);
C - RectangleF^ rectangle = gcnew RectangleF(10f, 10f, 450f, 25f);
array<Point^>^ points = gcnew array<Point^>^ {gcnew Point(0, 0), gcnew Point(110, 145)};
LinearGradientBrush^ rectangleBrush = gcnew LinearGradientBrush(rectangle, Color::AliceBlue, Color::CornflowerBlue, LinearGradientMode::ForwardDiagonal);
Pen^ rectanglePen = gcnew Pen(rectangleBrush);
Graphics^ g = this->CreateGraphics();
g->DrawPolygon(rectanglePen, points);
D - RectangleF^ rectangle = gcnew RectangleF(l0f, l0f, 450f, 25f);
SolidBrush^ rectangleBrush = gcnew SolidBrush(Color::AliceBlue);
Pen^ rectanglePen = gcnew Pen(rectangleBrush);
Graphics^ g = this->CreateGraphics();
g->DrawRectangle(rectangleBrush, rectangle);
Answer: B
K8 – rectangleBrush numbers w/out F
No comments:
Post a Comment