|
Microsoft 70-553(CSharp) Exam - ActualPaper.com Free 70-553(CSharp) Sample Questions:
Q: 1 You are creating a class that uses unmanaged resources. This class maintains
references to managed resources on other objects. You need to ensure that users of this class can
explicitly release resources when the class instance ceases to be needed. Which three actions should you
perform? (Each correct answer presents part of the solution. Choose three.)
A. Define the class such that it inherits from the WeakReference class.
B. Define the class such that it implements the IDisposable interface.
C. Create a class destructor that calls methods on other objects to release the managed resources.
D. Create a class destructor that releases the unmanaged resources.
E. Create a Dispose method that calls System.GC.Collect to force garbage collection.
F. Create a Dispose method that releases unmanaged resources and calls methods on other objects to release
the managed resources.
Answer: B, D, F
Q: 2 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
Q: 3 You need to create a method to clear a Queue named q. Which code segment
should you use?
A. foreach (object e in q) { q.Dequeue();}
B. foreach (object e in q) { Enqueue(null);}
C. q.Clear();
D. q.Dequeue();
Answer: C
Q: 4 You are developing an application that stores data about your company's
sales and technical support teams. You need to ensure that the name and contact information for each
person is available as a single collection when a user queries details about a specific team. You also need
to ensure that the data collection guarantees type safety. Which code segment should you use?
A. Hashtable team = new Hashtable();team.Add(1, "Hance");team.Add(2, "Jim");team.Add(3,
"Hanif");team.Add(4, "Kerim");team.Add(5, "Alex");team.Add(6, "Mark");team.Add(7, "Roger");team.Add(8,"Tommy");
B. ArrayList team = new ArrayList(); team.Add("1, Hance");team.Add("2, Jim");team.Add("3,
Hanif");team.Add("4, Kerim");team.Add("5, Alex");team.Add("6, Mark");team.Add("7, Roger");team.Add("8,
Tommy");
C. Dictionary<int, string> team = new Dictionary<int, string>(); team.Add(1, "Hance");team.Add(2,"Jim");team.Add(3, "Hanif");team.Add(4, "Kerim");team.Add(5, "Alex");team.Add(6, "Mark");team.Add(7,"Roger");team.Add(8, "Tommy");
D. string[] team = new string[] {"1, Hance", "2, Jim", "3, Hanif", "4, Kerim", "5, Alex",
"6, Mark", "7, Roger", "8, Tommy"};
Answer: C
Q: 5 You are developing a custom-collection class. You need to create a method
in your class. You need to ensure that the method you create in your class returns a type that is
compatible with the Foreach statement. Which criterion should the method meet?
A. The method must return a type of either IEnumerator or IEnumerable.
B. The method must return a type of IComparable.
C. The method must explicitly contain a collection.
D. The method must be the only iterator in the class.
Answer: A
Q: 6 You are writing a custom dictionary. The custom-dictionary class is named
MyDictionary. You need to ensure that the dictionary is type safe. Which code segment should you use?
A. class MyDictionary : Dictionary<string, string>
B. class MyDictionary : HashTable
C. class MyDictionary : IDictionary
D. class MyDictionary { ... } Dictionary<string, string> t = new Dictionary<string, string>();MyDictionary
dictionary = (MyDictionary)t;
Answer: A
Q: 7 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 = new FileSecurity("mydata.xml",
AccessControlSections.All);security.SetAccessRuleProtection(true, true);File.SetAccessControl("mydata.xml",
security);
B. FileSecurity security = new FileSecurity();security.SetAccessRuleProtection(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
Q: 8 You are developing an application that will deploy by using ClickOnce. You
need to test if the application executes properly. You need to write a method that returns the object,
which prompts the user to install a ClickOnce application. Which code segment should you use?
A. return ApplicationSecurityManager.ApplicationTrustManager;
B. return AppDomain.CurrentDomain.ApplicationTrust;
C. return new HostSecurityManager();
D. return SecurityManager.PolicyHierarchy();
Answer: A
Q: 9 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. AppDomain domain =
AppDomain.CurrentDomain;domain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal);
B. AppDomain domain = AppDomain.CurrentDomain;domain.SetThreadPrincipal(new
WindowsPrincipal(null));
C. AppDomain domain = AppDomain.CurrentDomain; domain.SetAppDomainPolicy(
PolicyLevel.CreateAppDomainLevel());
D. AppDomain domain = AppDomain.CurrentDomain;domain.SetPrincipalPolicy(
PrincipalPolicy.UnauthenticatedPrincipal);
Answer: D
Q: 10 You are writing code for user authentication and authorization. The
username, password, and roles are stored in your application data store. You need to establish a user
security context that will be used for authorization checks such as IsInRole. You write the following code
segment to authorize the user.
if (!TestPassword(userName, password))
throw new Exception("could not authenticate user");
String[] userRolesArray = LookupUserRoles(userName);
You need to complete this code so that it establishes the user security context. Which code segment
should you use?
A. GenericIdentity ident = new GenericIdentity(userName);GenericPrincipal currentUser = new
GenericPrincipal(ident, userRolesArray);Thread.CurrentPrincipal = currentUser;
B. WindowsIdentity ident = new WindowsIdentity(userName);WindowsPrincipal currentUser = new
WindowsPrincipal(ident);Thread.CurrentPrincipal = currentUser;
C. NTAccount userNTName = new NTAccount(userName);GenericIdentity ident = new
GenericIdentity(userNTName.Value);GenericPrincipal currentUser= new GenericPrincipal(ident,
userRolesArray);Thread.CurrentPrincipal = currentUser;
D. IntPtr token = IntPtr.Zero;token = LogonUserUsingInterop(userName,
encryptedPassword);WindowsImpersonationContext ctx = WindowsIdentity.Impersonate(token);
Answer: A
Q: 11 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
Q: 12 You are developing an auditing application to display the trusted ClickOnce
applications that are installed on a computer. You need the auditing application to display the origin of
each trusted application. Which code segment should you use?
A. ApplicationTrustCollection trusts;trusts = ApplicationSecurityManager.UserApplicationTrusts; foreach
(ApplicationTrust trust in trusts) { Console.WriteLine(trust.ToString());}
B. ApplicationTrustCollection trusts;trusts = ApplicationSecurityManager.UserApplicationTrusts; foreach
(ApplicationTrust trust in trusts) { Console.WriteLine(trust.ExtraInfo.ToString());}
C. ApplicationTrustCollection trusts;trusts = ApplicationSecurityManager.UserApplicationTrusts; foreach
(ApplicationTrust trust in trusts) { Console.WriteLine(trust.ApplicationIdentity.FullName);}
D. ApplicationTrustCollection trusts;trusts = ApplicationSecurityManager.UserApplicationTrusts; foreach
(object trust in trusts) { Console.WriteLine(trust.ToString());}
Answer: C
Q: 13 You are developing a method to call a COM component. You need to use
declarative security to explicitly request the runtime to perform a full stack walk. You must ensure that
all callers have the required level of trust for COM interop before the callers execute your method.
Which attribute should you place on the method?
A. [SecurityPermission( SecurityAction.Demand, Flags=SecurityPermissionFlag.UnmanagedCode)]
B. [SecurityPermission( SecurityAction.LinkDemand, Flags=SecurityPermissionFlag.UnmanagedCode)]
C. [SecurityPermission( SecurityAction.Assert, Flags = SecurityPermissionFlag.UnmanagedCode)]
D. [SecurityPermission( SecurityAction.Deny, Flags = SecurityPermissionFlag.UnmanagedCode)]
Answer: A
Q: 14 You are creating an assembly named Assembly1. Assembly1 contains a
public method. The global cache contains a second assembly named Assembly2. You must ensure that
the public method is only called from Assembly2. Which permission class should you use?
A. GacIdentityPermission
B. PublisherIdentityPermission
C. DataProtectionPermission
D. StrongNameIdentityPermission
Answer: D
Q: 15 You create a DirectorySecurity object for the working directory. You need
to identify the user accounts and groups that have read and write permissions. Which method should you
use on the DirectorySecurity object?
A. the GetAuditRules method
B. the GetAccessRules method
C. the AccessRuleFactory method
D. the AuditRuleFactory method
Answer: B
|