Learn About Upgrade: MCAD Skills to MCTS Windows Applications
By Certification Magazine —
1 | 2 | 3 |These questions are based on 70-553VB: Upgrade: MCAD Skills to MCTS Windows Applications by Using the Microsoft .NET Framework (VB.NET)
A Self Test Software Practice Test
Objective: Develop applications that use system types and collections.
Sub-objective: Manage a group of associated data in a .NET Framework application by using collections (Refer System.Collections namespace).
Single answer, multiple-choice
You are an application developer for your company. You are creating an application that uses a Queue class object named MyQueue to store messages sent by the user during application run time.
Before processing the user messages, you want to access the message at the beginning of the queue without removing it. Which method of the MyQueue object should you use?
A. Peek.
B. Dequeue.
C. Enqueue.
D. Contains.
Answer:
A
Tutorial:
You should use the Peek method to access the message that is stored at the beginning of the MyQueue object. The Peek method accesses the element stored at the beginning of the object of the Queue class without removing the element from the queue. The Queue class is a data structure for handling elements based on the First In First Out (FIFO) concept. According to the FIFO concept, elements that are stored first are processed first.
You should not use the Dequeue method of the Queue class because this method is used to remove the next element at the beginning of a Queue object. In this scenario, you want to access the next element at the beginning of the MyQueue object without removing it.
You should not use the Enqueue method of the Queue class because this method is used to add a new element to the end of a Queue object. In this scenario, you want to access the element stored at the beginning of the MyQueue object without removing it.
You should not use the Contains method of the Queue class because this method is used to verify whether the specified element exists for the Queue object instance or not. In this scenario, you want to access the message stored at the beginning of the MyQueue object without removing it.
Reference:
Objective: Implement serialization and input/output functionality in a .NET Framework application.
Sub-objective: Access files and folders by using the File System classes (Refer System.IO namespace).
Single answer, multiple-choice
You are an application developer for a company. You are creating a file management application to monitor the hosts file. You want to replace the hosts file if it has been changed. You need to display the size and whether the hosts file is set to read-only. Which code should you use?
A. Dim hosts As New _
File ("C:Windowssystem32driversetchosts")
Console.WriteLine("ReadOnly? " & hosts.IsReadOnly)
Console.WriteLine("Size: " & hosts.Length)
B. Dim hosts As New _
File ("C:Windowssystem32driversetchosts")
Console.WriteLine("ReadOnly? " & hosts.GetReadOnly())
Console.WriteLine("Size: " & hosts.GetLength())
C. Dim hosts As New _
FileInfo("C:Windowssystem32driversetchosts")
Console.WriteLine("ReadOnly? " & hosts.IsReadOnly)
Console.WriteLine("Size: " & hosts.Length)
D. Dim hosts As New _
FileInfo("C:Windowssystem32driversetchosts")
Console.WriteLine("ReadOnly? " & hosts.IsReadOnly)
Console.WriteLine("Size: " & hosts.Size)
Answer:
C
Tutorial:
You should use the following code to display the size and whether the hosts file is set to read-only:
Dim hosts As New _
FileInfo("C:Windowssystem32driversetchosts")
Console.WriteLine("ReadOnly? " & hosts.IsReadOnly)
Console.WriteLine("Size: " & hosts.Length)
This code instantiates a FileInfo object using a file path string and outputs the IsReadOnly and Length properties to the command line. The FileInfo object represents information about a system file. Whereas the File class contains only methods, the FileInfo class contains common properties and methods for reading and setting file metadata and contents. The IsReadOnly property returns a Boolean value indicating whether the file is set to read-only. The Length property returns the size of the file in bytes.
You should not use the code fragments that use the File class because the File class does not contain an IsReadOnly or Length property. Though the File class and FileInfo classes overlap in many ways, the FileInfo class offers properties the File class does not directly provide. This is the case with the IsReadOnly and Length property. You should use the FileInfo class in this scenario.
You should not use the code fragments that specify the GetReadOnly and GetLength methods or the Size property because no such methods or property exists.
Reference:
Objective: Improvie the security of .NET Framework applications by using the .NET Framework 2.0 security features.
Sub-objective: Access and modify identity information by using the System.Security.Principal classes (Refer System.Security.Principal namespace).
Single answer, multiple-choice
You are an application developer for a company. You are creating an application for displaying confidential employee information. This information should be available for viewing only by managers and administrators. You use Windows authentication and .NET role-based security to ensure this.
Your network administrator detects that certain users who are not managers or administrators are able to view the employee information. After examining your code, you determine an issue with domain group memberships.
You need to trace the user account and security identifier (SID) of each user in your application. The network administrator can use this information to detect users across the enterprise and verify their group memberships are correct. Which code should you use to trace the user account and SID of each user?
A. Dim curID As WindowsIdentity = WindowsIdentity.GetCurrent()
Dim sid As New SecurityIdentifier(curID.Name)
Trace.Write("User's SID is " & sid.Value, "User " & sid.Name)
B. Dim curID As WindowsIdentity = WindowsIdentity.GetCurrent()
Trace.Write("User's SID is " & curID.SID, "User " & curID.Name)
C. Dim curID As WindowsIdentity = WindowsIdentity.GetCurrent()
Dim account As New NTAccount(curID.Name)
Dim sid As SecurityIdentifier = _
CType(account.Translate( _
GetType(SecurityIdentifier)), SecurityIdentifier)
Trace.Write("User's SID is " & sid.Value, "User " & account.Value)
D. Dim curID As WindowsIdentity = WindowsIdentity.GetCurrent()
Dim account As New NTAccount(curID.Name)
Trace.Write("User's SID is " & account.SID, "User " & account.Name)




