Q1. - (Topic 2)
You are developing an application.
The application contains the following code segment (line numbers are included for reference only):
When you run the code, you receive the following error message: "Cannot implicitly convert type 'object'' to 'inf. An explicit conversion exists (are you missing a cast?)."
You need to ensure that the code can be compiled.
Which code should you use to replace line 05?
A. var2 = ((List<int>) array1) [0];
B. var2 = array1[0].Equals(typeof(int));
C. var2 = Convert.ToInt32(array1[0]);
D. var2 = ((int[])array1)[0];
Answer: A
Explanation: Make a list of integers of the array with = ( (List<int>)arrayl) then select the first item in the list with [0].
Q2. - (Topic 2)
You are developing an application that will process personnel records.
The application must encrypt highly sensitive data.
You need to ensure that the application uses the strongest available encryption.
Which class should you use?
A. System.Security.Cryptography.DES
B. System.Security.Cryptography.Aes
C. System.Security.Cryptography.TripleDES
D. System.Security.Cryptography.RC2
Answer: B
Q3. - (Topic 1)
You are modifying an application that processes leases. The following code defines the Lease class. (Line numbers are included for reference only.)
Leases are restricted to a maximum term of 5 years. The application must send a notification message if a lease request exceeds 5 years.
You need to implement the notification mechanism.
Which two actions should you perform? (Each correct answer presents part of the solution. Choose two.)
A. Option A
B. Option B
C. Option C
D. Option D
E. Option E
F. Option F
Answer: A,B
Q4. - (Topic 2)
You are implementing a new method named ProcessData. The ProcessData() method calls a third-party component that performs a long-running operation.
The third-party component uses the IAsyncResult pattern to signal completion of the long-running operation.
You need to ensure that the calling code handles the long-running operation as a System.Threading.Tasks.Task object.
Which two actions should you perform? (Each correct answer presents part of the solution. Choose two.)
A. Call the component by using the TaskFactory.FromAsync() method.
B. Create a TaskCompletionSource<T> object.
C. Apply the async modifier to the method signature.
D. Apply the following attribute to the method signature: [MethodImpl(MethodImplOptions.Synchronized)]
Answer: A,B
Explanation: A: TaskFactory.FromAsync Method
Creates a Task that represents a pair of begin and end methods that conform to the
Asynchronous Programming Model pattern. Overloaded.
Example:
TaskFactory.FromAsync Method (IAsyncResult, Action<IAsyncResult>)
Creates a Task that executes an end method action when a specified IAsyncResult
completes.
B: In many scenarios, it is useful to enable a Task<TResult> to represent an external asynchronous operation. TaskCompletionSource<TResult> is provided for this purpose. It enables the creation of a task that can be handed out to consumers, and those consumers can use the members of the task as they would any other. However, unlike most tasks, the state of a task created by a TaskCompletionSource is controlled explicitly by the methods on TaskCompletionSource. This enables the completion of the external asynchronous operation to be propagated to the underlying Task. The separation also ensures that consumers are not able to transition the state without access to the corresponding TaskCompletionSource.
Note:
* System.Threading.Tasks.Task Represents an asynchronous operation.
Q5. - (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
Q6. - (Topic 2)
You are implementing a new method named ProcessData. The ProcessData() method calls a third-party component that performs a long-running operation to retrieve stock information from a web service.
The third-party component uses the IAsyncResult pattern to signal completion of the long-running operation so that the UI can be updated with the new values.
You need to ensure that the calling code handles the long-running operation as a System.Threading.Tasks.Task object to avoid blocking the UI thread.
Which two actions should you perform? (Each correct answer presents part of the solution. Choose two.)
A. Create a TaskCompletionSource<T> object.
B. Call the component by using the TaskFactory.FromAsync() method.
C. Apply the following attribute to the ProcessData() method signature: [Methodlmpl(MethodlmplOptions.Synchronized)]
D. Apply the async modifier to the ProcessData() method signature.
Answer: A,B
Explanation: A: In many scenarios, it is useful to enable a Task<TResult> to represent an external asynchronous operation. TaskCompletionSource<TResult> is provided for this purpose. It enables the creation of a task that can be handed out to consumers, and those consumers can use the members of the task as they would any other. However, unlike most tasks, the state of a task created by a TaskCompletionSource is controlled explicitly by the methods on TaskCompletionSource. This enables the completion of the external asynchronous operation to be propagated to the underlying Task. The separation also ensures that consumers are not able to transition the state without access to the corresponding TaskCompletionSource.
B: TaskFactory.FromAsync Method
Creates a Task that represents a pair of begin and end methods that conform to the
Asynchronous Programming Model pattern. Overloaded.
Example:
TaskFactory.FromAsync Method (IAsyncResult, Action<IAsyncResult>)
Creates a Task that executes an end method action when a specified IAsyncResult completes.
Note:
* System.Threading.Tasks.Task Represents an asynchronous operation.
Q7. - (Topic 1)
You are adding a public method named UpdateGrade to a public class named ReportCard.
The code region that updates the grade field must meet the following requirements: . It must be accessed by only one thread at a time. . It must not be vulnerable to a deadlock situation. You need to implement the UpdateGrade() method.
What should you do?
A. Option A
B. Option B
C. Option C
D. Option D
Answer: A
Q8. DRAG DROP - (Topic 1)
You have a method named GetCustomerIDs that returns a list of integers. Each entry in the list represents a customer ID that is retrieved from a list named Customers. The Customers list contains 1,000 rows.
Another developer creates a method named ValidateCustomer that accepts an integer parameter and returns a Boolean value. ValidateCustomer returns true if the integer provided references a valid customer. ValidateCustomer can take up to one second to run.
You need to create a method that returns a list of valid customer IDs. The code must execute in the shortest amount of time.
What should you do? (Develop the solution by selecting and ordering the required code snippets. You may not need all of the code snippets.)
Answer:
Q9. - (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 be accessed and modified only by code within the Employee class or within a class derived from 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 05 with the following code segment: protected get;
B. Replace line 06 with the following code segment: private set;
C. Replace line 03 with the following code segment: public string EmployeeType
D. Replace line 05 with the following code segment: private get;
E. Replace line 03 with the following code segment: protected string EmployeeType
F. Replace line 06 with the following code segment: protected set;
Answer: B,E
Q10. - (Topic 1)
You are creating an application that manages information about zoo animals. The application includes a class named Animal and a method named Save.
The Save() method must be strongly typed. It must allow only types inherited from the Animal class that uses a constructor that accepts no parameters.
You need to implement the Save() method. Which code segment should you use?
A. Option A
B. Option B
C. Option C
D. Option D
Answer: C
Explanation:
When you define a generic class, you can apply restrictions to the kinds of types that client code can use for type arguments when it instantiates your class. If client code tries to instantiate your class by using a type that is not allowed by a constraint, the result is a compile-time error. These restrictions are called constraints. Constraints are specified by using the where contextual keyword. http://msdn.microsoft.com/en-us/library/d5x73970.aspx
Q11. HOTSPOT - (Topic 2)
You have the following code:
For each of the following statements, select Yes if the statement is true. Otherwise, select No.
Answer:
Q12. - (Topic 1)
An application will upload data by using HTML form-based encoding. The application uses a method named SendMessage.
The SendMessage() method includes the following code. (Line numbers are included for reference only.)
The receiving URL accepts parameters as form-encoded values.
You need to send the values intA and intB as form-encoded values named a and b,
respectively.
Which code segment should you insert at line 04?
A. Option A
B. Option B
C. Option C
D. Option D
Answer: D
Explanation:
WebClient.UploadValuesTaskAsync - Uploads the specified name/value collection to the resource identified by the specified URI as an asynchronous operation using a task object. These methods do not block the calling thread. http://msdn.microsoft.com/en-us/library/system.net.webclient.uploadvaluestaskasync.aspx
Q13. - (Topic 2)
You are developing an application that generates code. The application includes the following code segment. (Line numbers are included for reference only.)
You need to ensure that code generated by the GenerateCode() method represents a class that can be accessed by all objects in its application domain.
Which two code segments can you insert at line 05 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: A,C
Q14. - (Topic 2)
You have the following class (line numbers are included for reference only):
ServiceProxy is a proxy for a web service. Calls to the Update method can take up to five seconds. The Test class is the only class the uses Class1.
You run the Execute method three times, and you receive the following results: 312 231
You need to ensure that each value is appended to the Value property in the order that the Modify methods are invoked.
What should you do?
A. Option A
B. Option B
C. Option C
D. Option D
Answer: B
Q15. - (Topic 2)
You plan to store passwords in a Windows Azure SQL Database database.
You need to ensure that the passwords are stored in the database by using a hash algorithm,
Which cryptographic algorithm should you use?
A. ECDSA
B. RSA-768
C. AES-256
D. SHA-256
Answer: D