Q1. - (Topic 1)
You use the Task.Run() method to launch a long-running data processing operation. The data processing operation often fails in times of heavy network congestion.
If the data processing operation fails, a second operation must clean up any results of the first operation.
You need to ensure that the second operation is invoked only if the data processing operation throws an unhandled exception.
What should you do?
A. Create a task within the operation, and set the Task.StartOnError property to true.
B. Create a TaskFactory object and call the ContinueWhenAll() method of the object.
C. Create a task by calling the Task.ContinueWith() method.
D. Use the TaskScheduler class to create a task and call the TryExecuteTask() method on the class.
Answer: C
Explanation:
Task.ContinueWith - Creates a continuation that executes asynchronously when the target Task completes.The returned Task will not be scheduled for execution until the current task has completed, whether it completes due to running to completion successfully, faulting due to an unhandled exception, or exiting out early due to being canceled. http://msdn.microsoft.com/en-us/library/dd270696.aspx
Q2. - (Topic 2)
You are implementing a method named GetValidEmailAddresses. The GetValidEmailAddresses() method processes a list of string values that represent email addresses.
The GetValidEmailAddresses() method must return only email addresses that are in a valid format.
You need to implement the GetValidEmailAddresses() method.
Which two code segments can you use to achieve this goal? (Each correct answer presents a complete solution. Choose two.)
A. Option A
B. Option B
C. Option C
D. Option D
Answer: B,D
Explanation: Note:
* List<T>.Add Method
Adds an object to the end of the List<T>.
Q3. HOTSPOT - (Topic 2)
You have an existing order processing system that accepts .xml files,
The following code shows an example of a properly formatted order in XML:
You create the following class that will be serialized:
For each of the following properties, select Yes if the property is serialized according to the defined schema. Otherwise, select No.
Answer:
Q4. - (Topic 2)
You are creating a class library that will be used in a web application.
You need to ensure that the class library assembly is strongly named.
What should you do?
A. Use the csc.exe /target:Library option when building the application.
B. Use the AL.exe command-line tool.
C. Use the aspnet_regiis.exe command-line tool.
D. Use the EdmGen.exe command-line tool.
Answer: B
Explanation: The Windows Software Development Kit (SDK) provides several ways to sign an assembly with a strong name:
* Using the Assembly Linker (Al.exe) provided by the Windows SDK.
* Using assembly attributes to insert the strong name information in your code. You can use either the AssemblyKeyFileAttribute or the AssemblyKeyNameAttribute, depending on where the key file to be used is located.
* Using compiler options such /keyfile or /delaysign in C# and Visual Basic, or the
/KEYFILE or /DELAYSIGN linker option in C++. (For information on delay signing, see
Delay Signing an Assembly.)
Note:
* A strong name consists of the assembly's identity—it’s simple text name, version number, and culture information (if provided)—plus a public key and a digital signature. It is generated from an assembly file (the file that contains the assembly manifest, which in turn contains the names and hashes of all the files that make up the assembly), using the corresponding private key. Microsoft. Visual Studio. .NET and other development tools provided in the .NET Framework SDK can assign strong names to an assembly.
Assemblies with the same strong name are expected to be identical.
Q5. - (Topic 2)
You need to write a method that combines an unknown number of strings. The solution must minimize the amount of memory used by the method when the method executes.
What should you include in the code?
A. The String.Concat method
B. The StringBuilder.Append method
C. The + operator
D. The += operator
Answer: A
Explanation: A: String.Concat Method Concatenates one or more instances of String, or the String representations of the values of one or more instances of Object.
Q6. - (Topic 1)
You are developing an application. The application converts a Location object to a string by using a method named WriteObject.
The WriteObject() method accepts two parameters, a Location object and an XmlObjectSerializer object.
The application includes the following code. (Line numbers are included for reference only.)
You need to serialize the Location object as XML.
Which code segment should you insert at line 20?
A. new XmlSerializer(typeof(Location))
B. new NetDataContractSerializer()
C. new DataContractJsonSerializer(typeof (Location))
D. new DataContractSerializer(typeof(Location))
Answer: D
Explanation:
The code is using [DataContract] attribute here so need to used DataContractSerializer class.
Q7. - (Topic 2)
You are developing an application for a bank. The application includes a method named ProcessLoan that processes loan applications. The ProcessLoan() method uses a method named CalculateInterest. The application includes the following code:
You need to declare a delegate to support the ProcessLoan() method. Which code segment should you use?
A. Option A
B. Option B
C. Option C
D. Option D
Answer: C
Q8. - (Topic 2)
You are developing an application that uses multiple asynchronous tasks to optimize performance. The application will be deployed in a distributed environment.
You need to retrieve the result of an asynchronous task that retrieves data from a web service.
The data will later be parsed by a separate task. Which code segment should you use?
A. Option A
B. Option B
C. Option C
D. Option D
Answer: B
Q9. - (Topic 1)
You use the Task.Run() method to launch a long-running data processing operation. The data processing operation often fails in times of heavy network congestion.
If the data processing operation fails, a second operation must clean up any results of the first operation.
You need to ensure that the second operation is invoked only if the data processing operation throws an unhandled exception.
What should you do?
A. Create a TaskCompletionSource<T> object and call the TrySetException() method of the object.
B. Create a task by calling the Task.ContinueWith() method.
C. Examine the Task.Status property immediately after the call to the Task.Run() method.
D. Create a task inside the existing Task.Run() method by using the AttachedToParent option.
Answer: B
Q10. - (Topic 2)
You are troubleshooting an application that uses a class named FullName. The class is decorated with the DataContractAttribute attribute. The application includes the following code. (Line numbers are included for reference only.)
You need to ensure that the entire FullName object is serialized to the memory stream object.
Which code segment should you insert at line 09?
A. binary.WriteEndDocument();
B. binary.WriteEndDocumentAsync();
C. binary.WriteEndElementAsync();
D. binary.Flush();
Answer: A
Explanation: * DataContractSerializer.WriteEndObject Method (XmlDictionaryWriter) Writes the closing XML element using an XmlDictionaryWriter.
* Note on line 07: DataContractSerializer.WriteObject Method Writes all the object data (starting XML element, content, and closing element) to an XML document or stream.
XmlDictionaryWriter
Q11. DRAG DROP - (Topic 2)
You are developing a class named Temperature.
You need to ensure that collections of Temperature objects are sortable.
You have the following code:
Which code segments should you include in Target 1, Target 2 and Target 3 to complete the code? (To answer, drag the appropriate code segments to the correct targets in the answer area. Each code segment may be used once, more than once, or not at all. You may need to drag the split bar between panes or scroll to view content.)
Answer:
Q12. - (Topic 2)
You are developing an application that includes a method named SendMessage.
You need to ensure that the SendMessage() method is called with the required parameters.
Which two code segments can you use to achieve this goal? (Each correct answer presents a complete solution. Choose two.)
A. Option A
B. Option B
C. Option C
D. Option D
Answer: C,D
Explanation: D: ExpandoObject Represents an object whose members can be dynamically added and removed at run time. / The ExpandoObject class enables you to add and delete members of its instances at run time and also to set and get values of these members. This class supports dynamic binding, which enables you to use standard syntax like sampleObject.sampleMember instead of more complex syntax like sampleObject.GetAttribute("sampleMember"). / You can pass instances of the ExpandoObject class as parameters. Note that these instances are treated as dynamic objects in C# and late-bound objects in Visual Basic. This means that you do not have IntelliSense for object members and you do not receive compiler errors when you call non-existent members. If you call a member that does not exist, an exception occurs.
Note:
* Visual C# 2010 introduces a new type, dynamic. The type is a static type, but an object of type dynamic bypasses static type checking. In most cases, it functions like it has type object. At compile time, an element that is typed as dynamic is assumed to support any operation. Therefore, you do not have to be concerned about whether the object gets its value from a COM API, from a dynamic language such as IronPython, from the HTML Document Object Model (DOM), from reflection, or from somewhere else in the program. However, if the code is not valid, errors are caught at run time.
Q13. - (Topic 2)
You are modifying an existing application.
The application includes a Loan class and a Customer class. The following code segment defines the classes.
You populate a collection named customer-Collection with Customer and Loan objects by using the following code segment:
You create a largeCustomerLoans collection to store the Loan objects by using the following code segment:
Collection<Loan> largeCustomerLoans = new Collection<Loan>();
All loans with an Amount value greater than or equal to 4000 must be tracked.
You need to populate the largeCustomerLoans collection with Loan objects.
Which code segment should you use?
A. Option A
B. Option B
C. Option C
D. Option D
Answer: D
Explanation: Must add to the largeCustomerLoans collection, not the customerLoanCollection.
We iterate through each customer in customerCollection and check each loan belonging to this customer.
Q14. DRAG DROP - (Topic 1)
You are developing an application by using C#. The application includes an array of decimal values named loanAmounts. You are developing a LINQ query to return the values from the array.
The query must return decimal values that are evenly divisible by two. The values must be sorted from the lowest value to the highest value.
You need to ensure that the query correctly returns the decimal values.
How should you complete the relevant code? (To answer, drag the appropriate code segments to the correct locations in the answer area. Each code segment may be used once, more than once, or not at all. You may need to drag the split bar between panes or scroll to view content.)
Answer:
Q15. - (Topic 1)
You are creating a class named Employee. The class exposes a string property named EmployeeType. The following code segment defines the Employee class. (Line numbers are included for reference only.)
The EmployeeType property value must meet the following requirements:
. The value must be accessed only by code within the Employee class or within a class derived from the Employee class. . The value must be modified only by code within the Employee class.
You need to ensure that the implementation of the EmployeeType property meets the requirements.
Which two actions should you perform? (Each correct answer represents part of the complete solution. Choose two.)
A. Replace line 03 with the following code segment: public string EmployeeType
B. Replace line 06 with the following code segment: protected set;
C. Replace line 05 with the following code segment: private get;
D. Replace line 05 with the following code segment: protected get;
E. Replace line 03 with the following code segment: protected string EmployeeType
F. Replace line 06 with the following code segment: private set;
Answer: E,F