Free Cheat-test Samples and Demo Questions Download
Adobe exams Adobe
Apple exams Apple
Avaya exams Avaya
Check Point exams Check Point
Cisco exams Cisco
Citrix exams Citrix
CIW exams CIW
CompTIA exams CompTIA
CWNP exams CWNP
EC-Council exams EC-Council
EMC exams EMC
Exin exams Exin
Fortinet exams Fortinet
GIAC exams GIAC
Hitachi exams Hitachi
HP exams HP
IBM exams IBM
Isaca exams Isaca
ISC exams ISC
ISEB exams ISEB
Juniper exams Juniper
LPI exams LPI
McAfee exams McAfee
Microsoft exams Microsoft
Oracle exams Oracle
PMI exams PMI
Riverbed exams Riverbed
SNIA exams SAP
Sun exams SAS
Symantec exams Symantec
VMware exams VMware
All certification exams

Microsoft 70-552 Exam - Cheat-Test.com

Free 70-552 Sample Questions:

Q: 1 You are creating a class that performs complex financial calculations. The class contains a method named GetCurrentRate that retrieves the current interest rate and a variable named currRate that stores the current interest rate. You write serialized representations of the class.
You need to write a code segment that updates the currRate variable with the current interest rate when an instance of the class is deserialized. Which code segment should you use?
A. [OnSerializing]void UpdateValue (StreamingContext^ context) { currRate = GetCurrentRate();}
B. [OnSerializing]void UpdateValue(SerializationInfo^ info) { info->AddValue("currentRate",
GetCurrentRate());}
C. [OnDeserializing]void UpdateValue(SerializationInfo^ info) { info->AddValue("currentRate",
GetCurrentRate());}
D. [OnDeserialized]void UpdateValue(StreamingContext^ context) { currRate = GetCurrentRate();}
Answer: D

Q: 2 You create an application to send a message by e-mail. An SMTP server is available on the local subnet. The SMTP server is named smtp.contoso.com. To test the application, you use a source address, me@contoso.com, and a target address, you@contoso.com. You need to transmit
the e-mail message. Which code segment should you use?
A. MailAddress addrFrom("me@contoso.com", "Me");MailAddress addrTo("you@contoso.com",
"You");MailMessage message(%addrFrom, %addrTo);message.Subject = "Greetings!";message.Body ="Test";message.Dispose();
B. String^ strSmtpClient = "smtp.contoso.com";String^ strFrom = "me@contoso.com";String^ strTo ="you@contoso.com";String^ strSubject = "Greetings!";String^ strBody = "Test";MailMessage msg(strFrom, strTo, strSubject, strSmtpClient);
C. MailAddress addrFrom("me@contoso.com");MailAddress addrTo("you@contoso.com");MailMessage
message(%addrFrom, %addrTo);message.Subject = "Greetings!";message.Body = "Test";SmtpClient client("smtp.contoso.com");client.Send(%message);
D. MailAddress^ addrFrom = gcnew MailAddress("me@contoso.com", "Me");MailAddress^ addrTo =
gcnew MailAddress("you@contoso.com", "You");MailMessage^ message = gcnew MailMessage(addrFrom, addrTo);message->Subject = "Greetings!";message->Body = "Test";SocketInformation info;Socket^ client = gcnew Socket(info);System::Text::ASCIIEncoding^ enc = gcnew System::Text::ASCIIEncoding();array<unsigned char>^ msgBytes =
enc->GetBytes(message->ToString());client->Send(msgBytes);
Answer: C

Q: 3 You need to write a code segment that will add a string named strConn to the connection string section of the application configuration file. Which code segment should you use?
A. System::Configuration::Configuration^ myConfig = ConfigurationManager::OpenExeConfiguration(
ConfigurationUserLevel::None);myConfig->ConnectionStrings->ConnectionStrings->Add( gcnew
ConnectionStringSettings("ConnStr1", strConn));myConfig->Save();
B. System::Configuration::Configuration^ myConfig = ConfigurationManager::OpenExeConfiguration(
ConfigurationUserLevel::None);myConfig->ConnectionStrings->ConnectionStrings->Add( gcnew
ConnectionStringSettings("ConnStr1", strConn));ConfigurationManager::RefreshSection("ConnectionStrings");
C. ConfigurationManager::ConnectionStrings::Add( gcnew ConnectionStringSettings("ConnStr1",
strConn));ConfigurationManager::RefreshSection("ConnectionStrings");
D. ConfigurationManager::ConnectionStrings::Add( gcnew ConnectionStringSettings("ConnStr1",
strConn));System::Configuration::Configuration^ myConfig =
ConfigurationManager::OpenExeConfiguration( ConfigurationUserLevel::None);myConfig->Save();
Answer: A

Q: 4 You are using the Microsoft Visual Studio 2005 IDE to examine the output of a method that returns a string. You assign the output of the method to a string variable named fName.
You need to write a code segment that prints the following on a single line
The message: "Test Failed: "
The value of fName if the value of fName does not equal "John"
You also need to ensure that the code segment simultaneously facilitates uninterrupted execution of the application. Which code segment should you use?
A. Debug::Assert(fName == "John", "Test Failed: ", fName);
B. Debug::WriteLineIf(fName != "John", fName, "Test Failed");
C. if (fName != "John") { Debug::Print("Test Failed: "); Debug::Print(fName);}
D. if (fName != "John") { Debug::WriteLine("Test Failed: "); Debug::WriteLine(fName);}
Answer: B

Q: 5 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 gcnew HostSecurityManager();
D. return SecurityManager::PolicyHierarchy();
Answer: A

Q: 6 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 = gcnew SHA1CryptoServiceProvider();array<Byte>^hash =
nullptr;sha->TransformBlock(message, 0, message->Length, hash, 0);
B. SHA1 ^sha = gcnew SHA1CryptoServiceProvider();array<Byte>^hash =
BitConverter::GetBytes(sha->GetHashCode());
C. SHA1 ^sha = gcnew SHA1CryptoServiceProvider();array<Byte>^hash = sha->ComputeHash(message);
D. SHA1 ^sha = gcnew SHA1CryptoServiceProvider();sha->GetHashCode();array<Byte>^hash = sha->Hash;
Answer: C

Q: 7 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

Q: 8 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: 9 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 = gcnew
FileSecurity("mydata.xml",AccessControlSections::All);security->SetAccessRuleProtection(true,
true);File::SetAccessControl("mydata.xml", security);
B. FileSecurity^ security = gcnew 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: 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 server application that will transmit sensitive information on a network. You create an X509Certificate object named certificate and a TcpClient object named client. You need to create an SslStream to communicate by using the Transport Layer Security 1.0 protocol. Which code segment should you use?
A. SslStream^ ssl = gcnew SslStream(Client->GetStream());ssl->AuthenticateAsServer(certificate, false, SslProtocols::None, true);
B. SslStream ^ssl = gcnew SslStream(Client->GetStream());ssl->AuthenticateAsServer(certificate, false, SslProtocols::Ssl3, true);
C. SslStream ^ssl = gcnew SslStream(Client->GetStream());ssl->AuthenticateAsServer(certificate, false, SslProtocols::Ssl2, true);
D. SslStream ^ssl = gcnew SslStream(Client->GetStream());ssl->AuthenticateAsServer(certificate, false, SslProtocols::Tls, true);
Answer: D

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;for(int
i=0;i<trusts->Count;i++){ApplicationTrust^ trust = trusts[i];System::Console::WriteLine(trust->ToString());}
B. ApplicationTrustCollection^ trusts;trusts = ApplicationSecurityManager::UserApplicationTrusts;for(int
i=0;i<trusts->Count;i++){ApplicationTrust^ trust =
trusts[i];System::Console::WriteLine(trust->ExtraInfo->ToString());}
C. ApplicationTrustCollection^ trusts;trusts = ApplicationSecurityManager::UserApplicationTrusts;for(int
i=0;i<trusts->Count;i++){ApplicationTrust^ trust =
trusts[i];System::Console::WriteLine(trust->ApplicationIdentity->FullName);}
D. ApplicationTrustCollection^ trusts;trusts = ApplicationSecurityManager::UserApplicationTrusts;for(int
i=0;i<trusts->Count;i++){Object^ trust = trusts[i];System::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 developing a method to hash data for later verification by using the MD5 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 MD5. You also need to place the result into a byte array.
Which code segment should you use?
A. HashAlgorithm ^algo = HashAlgorithm::Create("MD5");hash = algo->ComputeHash(message);
B. HashAlgorithm ^algo = HashAlgorithm::Create("MD5");hash =
BitConverter::GetBytes(algo->GetHashCode());
C. HashAlgorithm ^algo;algo = HashAlgorithm::Create(message->ToString());hash = algo->Hash;
D. HashAlgorithm ^algo = HashAlgorithm::Create("MD5");hash = nullptr;algo->TransformBlock(message, 0, message->Length, hash, 0);
Answer: A

Q: 15 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(gcnew
WindowsPrincipal(nullptr));
C. AppDomain^ domain =
AppDomain::CurrentDomain;domain->SetAppDomainPolicy(PolicyLevel::CreateAppDomainLevel());
D. AppDomain^ domain =
AppDomain::CurrentDomain;domain->SetPrincipalPolicy(PrincipalPolicy::UnauthenticatedPrincipal);
Answer: D

Q: 16 You are developing an application that runs by using the credentials of the end user. Only users who are members of the Administrator group get permission to run the application.
You write the following security code to protect sensitive data within the application.
bool isAdmin = false;
WindowsBuiltInRole role = WindowsBuiltInRole.Administrator;
...
if (!isAdmin)
throw new Exception("User not permitted");
You need to add a code segment to this security code to ensure that the application throws an exception if a user is not a member of the Administrator group. Which code segment should you use?
A. WindowsPrincipal currentUser = (WindowsPrincipal)Thread.CurrentPrincipal;isAdmin =
currentUser.IsInRole(role);
B. WindowsIdentity currentUser = WindowsIdentity.GetCurrent();foreach (IdentityReference grp in
currentUser.Groups) { NTAccount grpAccount = ((NTAccount)grp.Translate(typeof(NTAccount)));
isAdmin = grp.Value.Equals(role); if (isAdmin) break;}
C. GenericPrincipal currentUser = (GenericPrincipal) Thread.CurrentPrincipal;isAdmin =
currentUser.IsInRole(role.ToString());
D. WindowsIdentity currentUser = (WindowsIdentity)Thread.CurrentPrincipal.Identity;isAdmin =
currentUser.Name.EndsWith("Administrator");
Answer: A

Q: 17 You need to create a method to clear a Queue named q. Which code segment should you use?
A. for each (Object^ e in q) { q.Dequeue();}
B. for each (Object^ e in q) { q.Enqueue(0);}
C. q.Clear();
D. q.Dequeue();
Answer: C

Q: 18 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: 19 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{};Dictionary<String^, String^> t = gcnew Dictionary<String^,
String^>();MyDictionary dictionary = (MyDictionary)t;
Answer: A

Q: 20 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 = gcnew Stack<String^>();
B. Stack undoBuffer = gcnew Stack();
C. Queue<String^> undoBuffer = gcnew Queue<String^>();
D. Queue undoBuffer = gcnew Queue();
Answer: A

Q: 21 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: 22 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 = gcnew 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 = gcnew 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 = gcnew 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. array<String^>^ team = gcnew array<String^> (8); team[0] = "1, Hance";team[1] = "2, Jim";team[2] = "3, Hanif";team[3] = "4, Kerim";team[4] = "5, Alex";team[5] = "6, Mark";team[6] = "7, Roger";team[7] = "8, Tommy";
Answer: C

Q: 23 You are writing a method to compress an array of bytes. The bytes to be compressed are passed to the method in a parameter named document. You need to compress the contents of the incoming parameter. Which code segment should you use?
A. MemoryStream^ inStream = gcnew MemoryStream(document);GZipStream^ zipStream = gcnew
GZipStream(inStream, CompressionMode::Compress); array<Byte>^ result = gcnew
array<Byte>(document->Length);zipStream->Write(result, 0, result->Length); return result;
B. MemoryStream^ stream = gcnew MemoryStream(document);GZipStream^ zipStream = gcnew
GZipStream(stream, CompressionMode::Compress);zipStream->Write(document, 0,
document->Length);zipStream->Close();return stream->ToArray();
C. MemoryStream^ outStream = gcnew MemoryStream();GZipStream^ zipStream = gcnew
GZipStream(outStream, CompressionMode::Compress);zipStream->Write(document, 0,
document->Length);zipStream->Close();return outStream->ToArray();
D. MemoryStream^ inStream = gcnew MemoryStream(document);GZipStream^ zipStream = gcnew
GZipStream(inStream, CompressionMode::Compress); MemoryStream^ outStream = gcnew
MemoryStream();int b;while ((b = zipStream->ReadByte()) != -1) { outStream->WriteByte((Byte)b);} return outStream->ToArray();
Answer: C

Q: 24 You are writing a method to compress an array of bytes. The array is passed to the method in a parameter named document. You need to compress the incoming array of bytes and return the result as an array of bytes. Which code segment should you use?
A. MemoryStream^ strm = gcnew MemoryStream(document);DeflateStream^ deflate = gcnew
DeflateStream(strm, CompressionMode::Compress); array<Byte>^ result = gcnew
array<Byte>(document->Length);deflate->Write(result, 0, result->Length); return result;
B. MemoryStream^ strm = gcnew MemoryStream(document);DeflateStream^ deflate = gcnew
DeflateStream(strm, CompressionMode::Compress);deflate->Write(document, 0,
document->Length);deflate->Close();return strm->ToArray();
C. MemoryStream^ strm = gcnew MemoryStream();DeflateStream^ deflate = gcnew DeflateStream(strm, CompressionMode::Compress);deflate->Write(document, 0, document->Length);deflate->Close();return strm->ToArray();
D. MemoryStream^ inStream = gcnew MemoryStream(document);DeflateStream^ deflate = gcnew
DeflateStream(inStream, CompressionMode::Compress); MemoryStream^ outStream = gcnew
MemoryStream();int b;while ((b = deflate->ReadByte()) != -1) { outStream->WriteByte((Byte)b);} return outStream->ToArray();
Answer: C

Q: 25 You create an application for your business partners to submit purchase orders. The application deserializes XML documents sent by your partners into instances of an object named PurchaseOrder. You need to modify the application so that it collects details if the deserialization
process encounters any XML content that fails to map to public members of the PurchaseOrder object.
What should you do?
A. Define and implement an event handler for the XmlSerializer.UnknownNode event.
B. Define a class that inherits from XmlSerializer and overrides the XmlSerialize.FromMappings method.
C. Apply an XmlInclude attribute to the PurchaseOrder class definition.
D. Apply an XmlIgnore attribute to the PurchaseOrder class definition.
Answer: A

Q: 26 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 ref class Employee {
02.
03. public :
04. String^ Name;
05. };
06.
07. public ref class Manager : public Employee {
08.
09. public :
10. int Level;11. };
12.
13. public ref class Group {
14.
15. public :
16. array<Employee^>^ Employees;
17. };
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 14 and 15 of the code segment: [XmlArrayItem(Type =
__typeof(Employee))] [XmlArrayItem(Type = __typeof(Manager))]
B. Insert the following code between lines 14 and 15 of the code segment: [XmlElement(Type =
__typeof(Employees))]
C. Insert the following code between lines 14 and 15 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 segment between lines 8 and 9 of the code
segment: [XmlElement(Type = __typeof(Manager))]
Answer: A

Q: 27 You are customizing a Windows Form to use a BackgroundWorker component named bgwExecute. bgwExecute performs a database operation in an event handler named WorkHandler. You need to ensure that users can see the progress of the database operation by viewing a progress bar named pbProgress. You want the progress bar to appear when the database operation is 50 percent complete. Which code segment should you use?
A. public: void StartBackground() { bgwExecute->WorkerReportsProgress = true;
bgwExecute->ProgressChanged += gcnew ProgressChangedEventHandler(this,
&SolutionA::ProgressChanged); bgwExecute->RunWorkerAsync();} void WorkHandler(Object^ sender, DoWorkEventArgs^ e){ bgwExecute->ReportProgress(50);} void ProgressChanged(Object^ sender, ProgressChangedEventArgs^ e){ pbProgress->Value = e->ProgressPercentage;}
B. public: void StartBackground() { bgwExecute->WorkerReportsProgress = true;
bgwExecute->ProgressChanged += gcnew ProgressChangedEventHandler(this,
&SolutionB::ProgressChanged); ThreadStart^ t = gcnew ThreadStart(this, &SolutionB::WorkHandler);
bgwExecute->RunWorkerAsync(t);} void WorkHandler() {bgwExecute->ReportProgress(50);} void
ProgressChanged(Object^ sender, ProgressChangedEventArgs^ e) {pbProgress->Value =
e->ProgressPercentage;}
C. public: void StartBackground() { bgwExecute->WorkerReportsProgress = true;
bgwExecute->ProgressChanged += gcnew ProgressChangedEventHandler(this,
&SolutionC::ProgressChanged); Thread^ t = gcnew Thread( gcnew ThreadStart(this,
&SolutionC::WorkHandler) ); bgwExecute->RunWorkerAsync(t);} void WorkHandler() {
bgwExecute->ReportProgress(50);} void ProgressChanged(Object^ sender, ProgressChangedEventArgs^ e) {
pbProgress->Value = e->ProgressPercentage;}
D. public: void StartBackground() { bgwExecute->WorkerReportsProgress = true; bgwExecute->DoWork
+= gcnew DoWorkEventHandler(this, &SolutionD::WorkHandler); bgwExecute->ProgressChanged +=
gcnew ProgressChangedEventHandler(this, &SolutionD::ProgressHandler);
bgwExecute->RunWorkerAsync();} void WorkHandler(Object^ sender, DoWorkEventArgs^ e) {
bgwExecute->ReportProgress(50);} void ProgressHandler(Object^ sender, ProgressChangedEventArgs^ e) {
pbProgress->Value = e->ProgressPercentage;}
Answer: D

Q: 28 You are customizing a Windows Form to update asynchronously a database in a method named WorkHandler. You need to ensure that the form displays a message box to the user that indicates the success or failure of the update. Which code segment should you use?
A. private: Void StartBackgroundProcess() { bgwExecute->DoWork += gcnew DoWorkEventHandler(this,
&Form1::WorkHandler); bgwExecute->RunWorkerCompleted += gcnew
RunWorkerCompletedEventHandler(this, &Form1::CompletedHandler);
bgwExecute->RunWorkerAsync();} Void CompletedHandler(Object^ sender,
RunWorkerCompletedEventArgs^ e){ bool result = (bool)e->Result; MessageBox::Show("Update " + (result ?
"was Successful" : "Failed"));} Void WorkHandler(Object^ sender, DoWorkEventArgs^ e) { //...
e->Result = true;}
B. private: Void StartBackgroundProcess() { bgwExecute->ProgressChanged += gcnew
ProgressChangedEventHandler(this, &Form1::ProgressHandler); ThreadStart^ tsBackground = gcnew ThreadStart(this, &Form1::WorkHandler); bgwExecute->RunWorkerAsync(tsBackground); } Void ProgressHandler(Object^ sender, ProgressChangedEventArgs^ e) { bool result = (bool)e->UserState;
MessageBox::Show("Update " + (result ? "was successful" : "failed"));} Void WorkHandler() {//...
bgwExecute->ReportProgress(100, true); }
C. private: Void StartBackgroundProcess(){ bgwExecute->RunWorkerCompleted += gcnew
RunWorkerCompletedEventHandler(this, &SolutionC::CompletedHandler); ThreadStart^ tsBackground = gcnew ThreadStart(this, &SolutionC::WorkHandler); bgwExecute->RunWorkerAsync(tsBackground);} Void
CompletedHandler(Object^ sender, RunWorkerCompletedEventArgs^ e){ bool result = (bool)e->Result;
MessageBox::Show("Update " + (result ? "was successful" : "Failed"));} Void WorkHandler() { //...
bgwExecute->ReportProgress(100, true);}
D. private: Void StartBackgroundProcess() { bgwExecute->DoWork += gcnew DoWorkEventHandler(this,
&SolutionD::WorkHandler); bgwExecute->RunWorkerCompleted += gcnew
RunWorkerCompletedEventHandler(this, &Form1::CompletedHandler);
bgwExecute->RunWorkerAsync();} Void CompletedHandler(Object^ sender,
RunWorkerCompletedEventArgs^ e){ bool result = (bool)e->Result; MessageBox::Show("Update " + (result ?"was successful" : "Failed"));} Void WorkHandler(Object^ sender, DoWorkEventArgs^ e) {//...
bgwExecute->ReportProgress(100, true);}
Answer: A


© 2014 Cheat-Test.com, All Rights Reserved