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#140 Q#150
Question: 140
You write the following code to call a function from the Win32 Application Programming Interface (API) by using platform invoke. int rc = MessageBox(hWnd, text, caption, type); You need to define a methon prototype. Which code segment should you use?
A. [DllImport("user32")]public static extern int MessageBox(int hWnd, String text, String caption, uint type);
B. [DllImport("user32")]public static extern int MessageBoxA(int hWnd, String text, String caption, uint type);
C. [DllImport("user32")]public static extern int Win32API_User32_MessageBox(
int hWnd, String text, String caption, uint type);
D. [DllImport(@"C:\WINDOWS\system32\user32.dll")]public static extern int
MessageBox(int hWnd, String text,
String caption, uint type);
Answer: A
K8 User32 & MessageBox
Question: 141
You need to generate a report that lists language codes and region codes. Which code segment should you use?
A. foreach (CultureInfo culture in
CultureInfo.GetCultures(CultureTypes.SpecificCultures)) {
// Output the culture information...}
B. CultureInfo culture = new CultureInfo(“”); CultureTypes types = culture.Culture Types;
// Output the culture information...
C. foreach (CultureInfo culture in
CultureInfo.GetCultures(CultureTypes.NeutralCultures)) {
// Output the culture information...}
D. foreach (CultureInfo culture in
CultureInfo.GetCultures(CultureTypes.ReplacementCultures)) {
// Output the culture information...}
Answer: A
K8 – Q: list of languages A: loop threw them & use SpecificCultures
Question: 142
You are developing a fiscal report for a customer. Your customer has a main office in the United States and a satellite office in Mexico. You need to ensure that when users in the satellite office generate the report, the current date is displayed in Mexican Spanish format. Which code segment should you use?
A. DateTimeFormatInfo dtfi = new CultureInfo(“es-MX”, false).DateTimeFormat;
DateTime dt = new DateTime(DateTime.Today.Year, DateTime.Today.Month,
DateTime.Today.Day); string dateString = dt.ToString(dtfi.LongDatePattern);
B. Calendar cal = new CultureInfo(“es-MX”, false).Calendar; DateTime dt = new
DateTime(DateTime.Today.Year, DateTime.Today.Month, DateTime.Today.Day);
Strong DateString = dt.ToString();
C. string dateString = DateTimeFormatInfo.CurrentInfo
GetMonthName(DateTime.Today.Month);
D. string dateString = DateTime.Today.Month.ToString(“es-MX”);
Answer: A
K8 – Date info from other locations
Question: 143
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 = gcnew ArrayList();
array<Process^> procs =
Process::GetProcessesByName(StrComputer);
for each (Process^ proc in procs) {
al->Add(proc);}
B. ArrayList^ al = gcnew ArrayList();
array<Process^> procs =
Process::GetProcesses(StrComputer);
for each (Process^ proc in procs) {
al->Add(proc);}
C. ArrayList^ al = gcnew ArrayList();
array<Process^> procs =
Process::GetProcessesByName(StrComputer);
for each (Process^ proc in procs) {
al->Add(proc->ProcessName);}
D. ArrayList^ al = gcnew ArrayList();
array<Process^> procs =
Process::GetProcesses(StrComputer);
for each (Process^ proc in procs) {
al->Add(proc->ProcessName);}
Answer: D
K8 – Q: Get Process names A: Use GetProcesses & add ProcessName
Question: 144
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 Sub StartService(ByVal serverName As String)
02 Dim crtl As ServiceController = _
03 New ServiceController("FileService")
04 If crtl.Status = ServiceControllerStatus.Stopped Then
05 End If
06 End Sub
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 – Q: Start app on server A: ctrl.MachineName & crtl.Start()
Question: 145
You are creating an application that retrieves values from a custom section of the application configuration file. The custom section uses XML as shown in the following block.
<ProjectSection name="ProjectCompany">
<role name="administrator" />
<role name="manager" />
<role name="support" />
</ProjectSection>
You need to write a code segment to define a class named Role. You need to ensure that the Role class is initialized with values that are retrieved from the custom section of the configuration file. Which code segment should you use?
A. public class Role : ConfigurationElement {
internal string_ElementName = “name”;
[ConfigurationProperty("role")]
public string Name {
get {
return ((string)base[“role”]);
} } }
B. public class Role : ConfigurationElement {
internal string_ElementName = “role”;
[ConfigurationProperty("name", RequiredValue = true)]
public string Name {
get {
return ((string)base[“name”]);
} } }
C. public class Role : ConfigurationElement {
internal string_ElementName = “role”;
private String_name;
[ConfigurationProperty("name")]
public string Name {
get {
return_name;
} } }
D. public class Role : ConfigurationElement {
internal string_ElementName = “name”;
private String_name;
[ConfigurationProperty("role", RequiredValue = true)]
public string Name {
get {
return_name;
} } }
Answer: B
K8 – Q: Retrieve values from config A: Role & ConfgProperty required value = True
Question: 146
You need to create a class definition that is interoperable along with COM. You need to ensure that COM applications can create instances of the class and can call the GetAddress method. Which code segment should you use?
A. public ref class Customer {
string addressString;
public: Customer(string address) : addressString(address) { }
String^ GetAddress() { return addressString; }}
B. public ref class Customer {
static string addressString;
public: Customer() { }
static String^ GetAddress() { return addressString; }}
C. public ref class Customer {
string; addressString
public: Customer() { }
String^ GetAddress() { return addressString; }}
D. public ref class Customer {
string addressString;
public: Customer() { }
private: String^ GetAddress() { return addressString; }}
Answer: C
K8 – String GetAddress() Customer()
Question: 147
You are developing an application to perform mathematical calculations. You develop a class named CalculationValues. You write a procedure named PerformCalculation that operates on an instance of the class. You need to ensure that the user interface of the application continues to respond while calculations are being performed. You need to write a code segment that calls the PerformCalculation procedure to achieve this goal. Which code segment should you use?
A. Private Sub PerformCalculation()...End Sub Private Sub DoWork()
Dim myValues As New CalculationValues()
Dim newThread As New Thread( _
New ThreadStart(AddressOf PerformCalculation))
newThread.Start(myValues)End Sub
B. Private Sub PerformCalculation()...End Sub Private Sub DoWork()
Dim myValues As New CalculationValues()
Dim delStart As New ThreadStart( _AddressOf PerformCalculation)
Dim newThread As New Thread(delStart)If newThread.IsAlive
ThennewThread.Start(myValues)End IfEnd Sub
C. Private Sub PerformCalculation ( _ByVal values As CalculationValues)...End Sub
Private Sub DoWork()
Dim myValues As New CalculationValues()
Application.DoEvents()
PerformCalculation(myValues)
Application.DoEvents()End Sub
D. Private Sub PerformCalculation ( _ByVal values As Object)...End Sub Private Sub
DoWork()
Dim myValues As New CalculationValues()
Dim newThread As New Thread( _
New ParameterizedThreadStart( _AddressOf PerformCalculation))
newThread.Start(myValues)End Sub
Answer: D
K8 – Q: Calculations & app continues to respond A: ParameterizedThreadStart
Question: 148
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 = gcnew ArrayList();
array<Process^> procs;
ProcessModuleCollection^ modules;
procs = Process::GetProcesses(@”Process1”);
if(procs->Length > 0) {
modules = procs[0]->Modules;
for each (ProcessModule^ mod in modules) {
ar->Add(mod->ModuleName);
}}
B. ArrayList^ ar = gcnew ArrayList();
array<Process^> procs;
ProcessModuleCollection modules;
procs = Process::GetProcesses(@”C:\TestApps\Process1.exe”);
if (procs->Length > 0) {
modules = procs[0]->Modules;
for each (ProcessModule^ mod in modules) {
ar->Add(mod->ModuleName);
}}
C. ArrayList^ ar = gcnew ArrayList();
array<Process^> procs;
ProcessModuleCollection modules;
procs = Process::GetProcesses(@”Process1”);
if (procs->Length > 0) {
modules = procs[0]->Modules;
for each (ProcessModule^ mod in modules) {
ar->Add(mod->FileName);
}}
D. ArrayList^ ar = gcnew ArrayList();
array<Process^> procs;
ProcessModuleCollection modules;procs = Process->GetProcessesByName(@”C:\TestApps\Process1.exe”);
if (procs->Length > 0) {
modules = procs[0]->Modules;
for each (ProcessModule^ mod in modules) {
ar->Add(mod->FileName);
}}
Answer: C
K8 – Q: Array name & path of modules loaded by an app Process1.exe A: @”Process1” & Filename
Question: 149
You write the following custom exception class named CustomException.
public class CustomException : ApplicationException {
public static int COR_E_ARGUMENT =
unchecked((int)0x80070057);
public CustomException(string msg) : base(msg) {
HResult = COR_E_ARGUMENT;
}} You need to write a code segment that will use the CustomException class to immediately return control to the COM caller. You also need to ensure that the caller has access to the error code. Which code segment should you use?
A. return Marshal.GetExceptionForHR(
CustomException.COR_E_ARGUMENT);
B. return CustomException.COR_E_ARGUMENT;
C. Marshal.ThrowExceptionForHR(
CustomException.COR_E_ARGUMENT);
D. throw new CustomException(“Argument is out of bounds”);
Answer: D
K8 – Q: CustomerException that immediately return control to COM A: throw exception.
Question: 150
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 Employee[] Employees;
03 }
04 public class Employee {
05 public string Name;
06 }
07 public class Manager : Employee {
08 public int Level;
09 }
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 = typeof(Employee))]
[XmlArrayItem(Type = typeof(Manager))]
B. Insert the following code between lines 1 and 2 of the code segment:
[XmlElement(Type = typeof(Employees))]
C. Insert the following code between lines 1 and 2 of the code segment:
[XmlArray(ElementName="Employees")]
D. Insert the following code between lines 3 and 4 of the code segment:
[XmlElement(Type = typeof(Employee))]
andInsert the following code between lines 6 and 7 of the code segment:
[XmlElement(Type = typeof(Manager))]
Answer: A
K8 – Q: Serialize instances of Group Class A: Both Employee & Manager
No comments:
Post a Comment