Saturday, August 29, 2009

70-536 MCTS .NET Foundations Questions #35

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

Q: #176 - #185

Question: 176

You develop a service application named FileService. You deploy the service application to multiple servers on your network. You implement the following code segment. (Line numbers are included for reference only.)

01 public :
02 void StartService(String^ serverName){
03
04 ServiceController^ crtl = gcnew
05 ServiceController(“FileService”);
06 if (crtl->Status == ServiceControllerStatus::Stopped){}
07 }

You need to develop a routine that will start FileService if it stops. The routine must start FileService on the server identified by the serverName input parameter. Which two lines of code should you add to the code segment? (Each correct answer presents part of the solution. Choose two.)

A. Insert the following line of code between lines 03 and 04:crtl.ServiceName = serverName;

B. Insert the following line of code between lines 03 and 04:crtl.MachineName = serverName;

C. Insert the following line of code between lines 03 and 04:crtl.Site.Name = serverName;

D. Insert the following line of code between lines 04 and 05:crtl.Continue();

E. Insert the following line of code between lines 04 and 05:crtl.Start();

F. Insert the following line of code between lines 04 and 05:crtl.ExecuteCommand(0);

Answer: B, E

K8 – Repeated questions are easier the 4th time. Crtl.MachineName = serverName & crtl.Start()

Question: 177

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

K8 – FileSecurity & AccessControlSections

Question: 178

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 = gcnew CompanyClass();
Type^ t = CompanyClass::typeid;
MethodInfo^m = t->GetMethod(“MyMethod”);
int i = (int)m->Invoke(this, gcnew array<Object^> {1});

B. CompanyClass^ myClass = gcnew CompanyClass();
Type^ t = CompanyClass::typeid;
MethodInfo^m = t->GetMethod(“MyMethod”);
int i = (int)m->Invoke(myClass, gcnew array<Object^> {1});

C. CompanyClass^ myClass = gcnew CompanyClass();
Type^ t = CompanyClass::typeid;
MethodInfo^m = t->GetMethod(“CompanyClass.MyMethod”);
int i = (int)m->Invoke(myClass, gcnew array<Object^> {1});

D. Type^ t =Type::GetType(“CompanyClass”);
MethodInfo^m = t->GetMethod(“MyMethod”);
int i = (int)m->Invoke(this, gcnew array<Object^> {1});

Answer: B

K8 – Q: Call function dynamically.

Question: 179

You are creating a class to compare a specially-formatted string. The default collation comparisons do not apply. You need to implement the IComparable<string> interface.
Which code segment should you use?

A. public class Person : IComparable<string>{
public int CompareTo(string other){
}}

B. public class Person : IComparable<string>{
public int CompareTo(object other){
}}

C. public class Person : IComparable<string>{
public bool CompareTo(string other){
}}

D. public class Person : IComparable<string>{
public bool CompareTo(object other){
}}

Answer: A

K8 – Compare special string A: int CompareTo(string

Question: 180

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. public ref class MYDictionary : public Dictionary<String^, String^>{};

B. public ref class MYDictionary : public Hashtable{};

C. public ref class MYDictionary : public IDictionary{};

D. public ref class MYDictionary {};Distionary<String^, String^>t = gcnew Dictionary<String^, String^>();
MyDictionary dictionary = (MyDictionary)t;

Answer: A

K8 – Type Safe so use <String>

Question: 181

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?

Exhibit:

A. Dim objRect As New Rectangle(10, 10, 450, 25)
Dim objBrush As New LinearGradientBrush( _objRect, Color.AliceBlue, Color.CornflowerBlue, _LinearGradientMode.ForwardDiagonal)
Dim objPen As New Pen(objBrush)Dim g As Graphics =
myForm.CreateGraphicsg.DrawRectangle(objPen, objRect)

B. Dim objRect As New Rectangle(10, 10, 450, 25)
Dim objBrush As New LinearGradientBrush( _
objRect, Color.AliceBlue, Color.CornflowerBlue, _
LinearGradientMode.ForwardDiagonal)
Dim objPen As New Pen(objBrush)
Dim g As Graphics = myForm.CreateGraphicsg.FillRectangle(objBrush, objRect)

C. Dim objRect As New RectangleF(10.0F, 10.0F, 450.0F, 25.0F)
Dim points() As System.Drawing.Point = _
{New Point(0, 0), New Point(110, 145)}
Dim objBrush As New LinearGradientBrush( _
objRect, Color.AliceBlue, Color.CornflowerBlue, _
LinearGradientMode.ForwardDiagonal)
Dim objPen As New Pen(objBrush)
Dim g As Graphics = myForm.CreateGraphicsg.DrawPolygon(objPen, points)

D. Dim objRect As New Rectangle(10, 10, 450, 25)
Dim objBrush As New SolidBrush(Color.AliceBlue)
Dim objPen As New Pen(objBrush)Dim g As Graphics =
myForm.CreateGraphicsg.DrawRectangle(objPen, objRect)

Answer: B

K8 - Gradient Brush object.

Question: 182

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

K8 – All callers have required trust A: Demand

Question: 183

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 = new ArrayList();
lock (al.SyncRoot){
return al;}

B. ArrayList al = new ArrayList();
lock (al.SyncRoot.GetType()){
return al;}

C. ArrayList al = new ArrayList();
Monitor.Enter(al);Monitor.Exit(al);return al;

D. ArrayList al = new ArrayList();
ArrayList sync_al = ArrayList.Synchronized(al);
return sync_al;

Answer: D

K8 – Q: Changes to ArrayList Thread safe A: ArrayList sync_al

Question: 184

You are loading a new assembly into an application. You need to override the default evidence for the assembly. You require the common language runtime (CLR) to grant the assembly a permission set, as if the assembly were loaded from the local intranet zone. You need to build the evidence collection. Which code segment should you use?

A. Dim objEvidence As New Evidence( _
Assembly.GetExecutingAssembly.Evidence

B. Dim objEvidence As New EvidenceobjEvidence.AddAssembly( _
New Zone(SecurityZone.Intranet))

C. Dim objEvidence As New EvidenceobjEvidence.AddHost( _
New Zone(SecurityZone.Intranet))

D. Dim objEvidence As New Evidence( _

AppDomain.CurrentDomain.Evidence)

Answer: C

K8 Q: Grant Assembly permission A: AddHost

Question: 185

You are creating an application that lists processes on remote computers. The application requires a method that performs the following tasks: Accept the remote computer name as a string parameter named strComputer.Return an ArrayList object that contains the names of all processes that are running on that computer. You need to write a code segment that retrieves the name of each process that is running on the remote computer and adds the name to the ArrayList
object. Which code segment should you use?

A. ArrayList al = new ArrayList();
Process[] procs = Process.GetProcessesByName(s trComputer);
foreach (Process proc in procs) {
al.Add(proc);}

B. ArrayList al = new ArrayList();
Process[] procs = Process.GetProcesses(strComputer);
foreach (Process proc in procs) {
al.Add(proc);}

C. ArrayList al = new ArrayList();
Process[] procs = Process.GetProcessesByName(s trComputer);
foreach (Process proc in procs) {
al.Add(proc.ProcessName);}

D. ArrayList al = new ArrayList();
Process[] procs = Process.GetProcesses(strComputer);
foreach (Process proc in procs) {
al.Add(proc.ProcessName);}

Answer: D

K8 Get Process

1 comment:

Anonymous said...

good stuff, thx.