You need to write a code segment that performs the following tasks: * Retrieves the name of each paused service. * Passes the name to the Add method of Collection1. Which code segment should you use?

You need to write a code segment that performs the following tasks:

* Retrieves the name of each paused service.
* Passes the name to the Add method of Collection1.

Which code segment should you use?

 A. ManagementObjectSearcher^ searcher =
    gcnew ManagementObjectSearcher(
    “Select * from Win32_Service where State = ‘Paused’”);for each (ManagementObject^
    svc in searcher->Get()) {
    Collection1->Add(svc[“DisplayName”]);}
B. ManagementObjectSearcher^ searcher =
    gcnew ManagementObjectSearcher(
    “Select * from Win32_Service”, “State = ‘Paused’”);for each (ManagementObject^ svc in
    searcher->Get()) {
    Collection1->Add(svc[“DisplayName”]);}
C. ManagementObjectSearcher^ searcher =
    gcnew ManagementObjectSearcher(
    “Select * from Win32_Service”);for each (ManagementObject^ svc in searcher->Get()) {
    if ((String^) svc["State"] == "'Paused'") {
    Collection1->Add(svc[“DisplayName”]);
    }}
D. ManagementObjectSearcher^ searcher =
    gcnew ManagementObjectSearcher();searcher->Scope = gcnew
    ManagementScope(“Win32_Service”);for each (ManagementObject^ svc in
    searcher->Get()) {
    if ((String^)svc["State"] == "Paused") {
    Collection1->Add(svc[“DisplayName”]);
    }}

Answer: A

No comments:

Post a Comment