Saturday, August 29, 2009

70-536 MCTS .NET Foundations Questions #34

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

#167 - #175

 

Question: 167

You create a class library that is used by applications in three departments of your company. The library contains a Department class with the following definition.

Public Class Department

Public name As String

Public manager As String

End Class

Each application uses a custom configuration section to store department-specific values in the application configuration file as shown in the following code.

<Department>

<name>Hardware</name>

<manager>Company</manager>

</Department>

You need to write a code segment that creates a Department object instance by using the field values retrieved from the application configuration file. Which code segment should you use?

A. Public Class deptElement
Inherits ConfigurationElement
Protected Overrides Sub DeserializeElement( _
ByVal reader As XmlReader, _
ByVal serializeCollectionKey As Boolean)
Dim dept As Department = New Department()
dept.name = ConfigurationManager.AppSettings("name")
dept.manager = _
ConfigurationManager.AppSettings("manager")
End Sub
End Class

B. Public Class deptElement
Inherits ConfigurationElement
Protected Overrides Sub DeserializeElement( _
ByVal reader As XmlReader, _
ByVal serializeCollectionKey As Boolean)
Dim dept As Department = New Department()
dept.name = reader.GetAttribute("name")
dept.manager = reader.GetAttribute("manager")
End Sub
End Class

C. Public Class deptHandler
Implements IConfigurationSectionHandler
Public Function Create(ByVal parent As Object, _
ByVal configContext As Object, _
ByVal section As System.Xml.XmlNode) As Object _
Implements IConfigurationSectionHandler.Create
Dim dept As Department = new Department()
dept.name = section.SelectSingleNode("name").InnerText
dept.manager = _
section.SelectSingleNode("manager").InnerText
Return dept
End Function
End Class

D. Public Class deptHandler
Implements IConfigurationSectionHandler
Public Function Create(ByVal parent As Object, _
ByVal configContext As Object, _
ByVal section As System.Xml.XmlNode) As Object _
Implements IConfigurationSectionHandler.Create
Dim dept As Department = new Department()
dept.name = section.Attributes("name").Value
dept.manager = section.Attributes("manager").Value
Return dept
End Function
End Class

Answer: C

K8 – A: IconfigurationSectionHandler & SelectSingleNode

Question: 168

You are writing a method that returns an ArrayList named al. You need to ensure that changes to the ArrayList are performed in a thread-safe manner. Which code segment should you use?

A. ArrayList^ al = gcnew ArrayList();
lock (al->SyncRoot){
return al;}

B. ArrayList^ al = gcnew ArrayList();
lock (al->SyncRoot.GetType()){
return al;}

C. ArrayList^ al = gcnew ArrayList();
Monitor::Enter(al);
Monitor::Exit(al);
return al;

D. ArrayList^ al = gcnew ArrayList();
ArrayList^ sync_al = ArrayList::Synchronized(al);
return sync_al;

Answer: D

K8 – Q: Thread safe manner to changes in array list A: Synchronized

Question: 169

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. Dim memStream As New MemoryStream(8192)memStream.Write(dataToSend, 0, _
CType(netStream.Length, Integer))

B. Dim memStream As New MemoryStream(8192)netStream.Write(dataToSend, 0, _
CType(memStream.Length, Integer))

C. Dim bufStream As New BufferedStream(netStream, 8192)
bufStream.Write(dataToSend, 0, dataToSend.Length)

D. Dim bufStream As New BufferedStream(netStream)
bufStream.Write(dataToSend, 0, 8192)

Answer: C

K8 – BufferedStream(networkStream, CasheBytes)

Question: 170

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. Dim undoBuffer As New Stack(Of String)

B. Dim undoBuffer As New Stack()

C. Dim undoBuffer As New Queue(Of String)

D. Dim undoBuffer As New Queue()

Answer: A

K8 – Stack Last in first out combied with of string this is VB version

Question: 171

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 = new Stack<string>();

B. Stack undoBuffer = new Stack();

C. Queue<string> undoBuffer = new Queue<string>();

D. Queue undoBuffer = new Queue();

Answer: A

K8 – Stack Last in first out combied with of string C#

Question: 172

You create the definition for a Vehicle class by using the following code segment.

public class Vehicle {
[XmlAttribute(AttributeName = "category")]
public string vehicleType;
public string model;
[XmlIgnore]
public int year;
[XmlElement(ElementName = "mileage")]
public int miles;
public ConditionType condition;
public Vehicle() {
}
public 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:

MemberValuevehicleTypecarmodelraceryear2002miles15000conditionAboveAverage 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 – Car category along with condition Excellent.

Question: 173

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 i As Integer = 1 To 80
stream1.WriteByte(byteArray(i))
bytesTransferred = i
If Not stream1.CanWrite Then
Exit For
End IfNext

C. While bytesTransferred < 80
stream1.Seek(1, SeekOrigin.Current)
byteArray(bytesTransferred) = _
Convert.ToByte(stream1.ReadByte())bytesTransferred += 1End While

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

Answer: A

K8 – Bytes transferred with no loop

Question: 174

You are changing the security settings of a file named MyData.xml. You need to preserve the existing inherited access rules. You also need to prevent the access rules from inheriting changes in the future. Which code segment should you use?

A. FileSecurity^ security = gcnew FileSecurity(“mydata.xml”, AccessControlSections::All);
security->SetAccessRuleProtection( true, true);
File::SetAccessControl(“mydata.xml”, security);

B. FileSecurity^ security = gcnew FileSecurity();
security->SetAccess RuleProtection(true,true);
File::SetAccessControl(“mydata.xml”, security);

C. FileSecurity^ security = File::GetAccessControl(“mydata.xml”);
security->SetAccessRuleProtection(true, true);

D. FileSecurity^ security =
File::GetAccessControl(“mydata.xml”);security->SetAuditRuleProtection(true, true);
File::SetAccessControl(“mydata.xml”, security);

Answer: A

K8 – Change Security Settings … FileSecurity

Question: 175

You are testing a component that serializes the Meeting class instances so that they can be saved to the file system. The Meeting class has the following definition:

public class Meeting {
private string title;
public int roomNumber;
public string[] invitees;
public Meeting(){
}
public Meeting(string t){
title = t;
} }

The component contains a procedure with the following code segment.
Meeting myMeeting = new Meeting(“Goals”);
myMeeting.roomNumber = 1100;
string[] attendees = new string[2]{“Company”, “Mary”};
myMeeting.invitees = attendees;
XmlSerializer xs = new XmlSerializer(typeof(Meeting));
StreamWriter writer = new StreamWriter(@"C:\Meeting.xml");
Xs.Serialize(writer, myMeeting);
writer.Close();

You need to identify the XML block that is written to the C:\Meeting.xml file as a result of running this procedure. Which XML block represents the content that will be written to the C:\Meeting.xml file?

A. <?xml version="1.0" encoding="utf-8"?>
<Meeting xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<title>Goals</title>
<roomNumber>1100</roomNumber>
<invitee>Company</invitee>
<invitee>Mary</invitee>
</Meeting>

B. <?xml version="1.0" encoding="utf-8"?>
<Meeting xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<roomNumber>1100</roomNumber>
<invitees>
<string>Company</string>
<string>Mary</string>
</invitees>
</Meeting>

C. <?xml version="1.0" encoding="utf-8"?>
<Meeting xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
title="Goals">
<roomNumber>1100</roomNumber> <invitees>
<string>Company</string>
<string>Mary</string>
</invitees>
</Meeting>

D. <?xml version="1.0" encoding="utf-8"?>
<Meeting xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <roomNumber>1100</roomNumber>
<invitees>
<string>Company</string>
</invitees>
<invitees>
<string>Mary</string>
</invitees>
</Meeting>

Answer: B

K8 – XML

No comments: