Q1. HOTSPOT - (Topic 1)
You are reviewing the following code:
For each of the following statements, select Yes if the statement is true. Otherwise, select No.
Answer:
Q2. - (Topic 2)
You are developing an application that includes methods named ConvertAmount and TransferFunds.
You need to ensure that the precision and range of the value in the amount variable is not lost when the TransferFunds() method is called.
Which code segment should you use?
A. Option A
B. Option B
C. Option C
D. Option D
Answer: A
Explanation: The double keyword signifies a simple type that stores 64-bit floating-point values.
The float keyword signifies a simple type that stores 32-bit floating-point values.
Reference: double (C# Reference)
Q3. - (Topic 2)
You are developing an application that will be deployed to multiple computers. You set the assembly name.
You need to create a unique identity for the application assembly.
Which two assembly identity attributes should you include in the source code? (Each correct answer presents part of the solution. Choose two.)
A. AssemblyTitleAttribute
B. AssemblyCultureAttribute
C. AssemblyVersionAttribute
D. AssemblyKeyNameAttribute
E. AssemblyFileVersion
....
Answer: B,C
Explanation: The AssemblyName object contains information about an assembly, which you can use to bind to that assembly. An assembly's identity consists of the following:
Simple name
Version number
Cryptographic key pair
Supported culture
B: AssemblyCultureAttribute
Specifies which culture the assembly supports.
The attribute is used by compilers to distinguish between a main assembly and a satellite
assembly. A main assembly contains code and the neutral culture's resources. A satellite
assembly contains only resources for a particular culture, as in
[assembly:AssemblyCultureAttribute("de")]
C: AssemblyVersionAttribute
Specifies the version of the assembly being attributed.
The assembly version number is part of an assembly's identity and plays a key part in
binding to the assembly and in version policy.
Q4. - (Topic 2)
You are evaluating a method that calculates loan interest. The application includes the following code segment. (Line numbers are included for reference only.)
When the loanTerm value is 5 and the loanAmount value is 4500, the loanRate must be set to 6.5 percent.
You need to adjust the loanRate value to meet the requirements.
What should you do?
A. Replace line 15 with the following code segment: loanRate = 0.065m;
B. Replace line 07 with the following code segment: loanRate = 0.065m;
C. Replace line 17 with the following code segment: interestAmount = loanAmount * 0.065m * loanTerm;
D. Replace line 04 with the following code segment: decimal loanRate = 0.065m;
Answer: A
Q5. - (Topic 1)
An application receives JSON data in the following format:
The application includes the following code segment. (Line numbers are included for reference only.)
You need to ensure that the ConvertToName() method returns the JSON input string as a Name object.
Which code segment should you insert at line 10?
A. Return ser.Desenalize (json, typeof(Name));
B. Return ser.ConvertToType<Name>(json);
C. Return ser.Deserialize<Name>(json);
D. Return ser.ConvertToType (json, typeof (Name));
Answer: C
Q6. DRAG DROP - (Topic 1)
You are creating a class named Data that includes a dictionary object named _data.
You need to allow the garbage collection process to collect the references of the _data object.
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:
Q7. - (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
Q8. DRAG DROP - (Topic 2)
You have an application that accesses a Microsoft SQL Server database.
The database contains a stored procedure named Proc1. Proc1 accesses several rows of data across multiple tables.
You need to ensure that after Proc1 executes, the database is left in a consistent state. While Proc1 executes, no other operation can modify data already read or changed by Proc1. (Develop the solution by selecting and ordering the required code snippets.
You may not need all of the code snippets.)
Answer:
Q9. - (Topic 2)
You develop an application by using C#. The application counts the number of times a specific word appears within a set of text files. The application includes the following code. (Line numbers are included for reference only.)
You have the following requirements:
. Populate the _wordCounts object with a list of words and the number of occurrences of each word. . Ensure that updates to the ConcurrentDictionary object can happen in parallel.
You need to complete the relevant code.
Which code segment should you insert at line 23?
A. Option A
B. Option B
C. Option C
D. Option D
Answer: A
Q10. - (Topic 1)
You are developing an application by using C#.
The application includes an object that performs a long running process.
You need to ensure that the garbage collector does not release the object's resources until the process completes.
Which garbage collector method should you use?
A. WaitForFullGCComplete()
B. SuppressFinalize()
C. collect()
D. RemoveMemoryPressure()
Answer: B
Q11. - (Topic 1)
You are developing an application that will convert data into multiple output formats.
The application includes the following code. (Line numbers are included for reference only.)
You are developing a code segment that will produce tab-delimited output. All output routines implement the following interface:
You need to minimize the completion time of the GetOutput() method. Which code segment should you insert at line 06?
A. Option A
B. Option B
C. Option C
D. Option D
Answer: B
Explanation:
A String object concatenation operation always creates a new object from the existing string and the new data. A StringBuilder object maintains a buffer to accommodate the concatenation of new data. New data is appended to the buffer if room is available; otherwise, a new, larger buffer is allocated, data from the original buffer is copied to the new buffer, and the new data is then appended to the new buffer. The performance of a concatenation operation for a String or StringBuilder object depends on the frequency of memory allocations. A String concatenation operation always allocates memory, whereas a StringBuilder concatenation operation allocates memory only if the StringBuilder object buffer is too small to accommodate the new data. Use the String class if you are concatenating a fixed number of String objects. In that case, the compiler may even combine individual concatenation operations into a single operation. Use a StringBuilder object if you are concatenating an arbitrary number of strings; for example, if you're using a loop to concatenate a random number of strings of user input.
http://msdn.microsoft.com/en-us/library/system.text.stringbuilder(v=vs.110).aspx
Q12. - (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.
Q13. - (Topic 1)
You are developing an application by using C#.
The application includes an object that performs a long running process.
You need to ensure that the garbage collector does not release the object's resources until
the process completes.
Which garbage collector method should you use?
A. WaitForFullGCComplete()
B. WaitForFullGCApproach()
C. KeepAlive()
D. WaitForPendingFinalizers()
Answer: C
Explanation: The GC.KeepAlive method references the specified object, which makes it ineligible for garbage collection from the start of the current routine to the point where this method is called. The purpose of the KeepAlive method is to ensure the existence of a reference to an object that is at risk of being prematurely reclaimed by the garbage collector. The KeepAlive method performs no operation and produces no side effects other than extending the lifetime of the object passed in as a parameter.
Q14. HOTSPOT - (Topic 1)
You are developing an application in C#.
The application will display the temperature and the time at which the temperature was recorded. You have the following method (line numbers are included for reference only):
You need to ensure that the message displayed in the lblMessage object shows the time formatted according to the following requirements:
The time must be formatted as hour:minute AM/PM, for example 2:00 PM.
The date must be formatted as month/day/year, for example 04/21/2013.
The temperature must be formatted to have two decimal places, for example 23-
45.
Which code should you insert at line 04? (To answer, select the appropriate options in the answer area.)
Answer:
Q15. - (Topic 1)
You are testing an application. The application includes methods named CalculateInterest and LogLine. The CalculateInterest() method calculates loan interest. The LogLine() method sends diagnostic messages to a console window.
The following code implements the methods. (Line numbers are included for reference only.)
You have the following requirements:
. The Calculatelnterest() method must run for all build configurations. . The LogLine() method must run only for debug builds.
You need to ensure that the methods run correctly.
What are two possible ways to achieve this goal? (Each correct answer presents a complete solution. Choose two.)
A. Insert the following code segment at line 01:
#region DEBUG
Insert the following code segment at line 10:
#endregion
B. Insert the following code segment at line 10:
[Conditional(MDEBUG")]
C. Insert the following code segment at line 05:
#region DEBUG
Insert the following code segment at line 07:
#endregion
D. Insert the following code segment at line 01:
#if DE30G
Insert the following code segment at line 10:
#endif
E. Insert the following code segment at line 01:
[Conditional(MDEBUG")]
F. Insert the following code segment at line 05:
#if DEBUG
Insert the following code segment at line 07:
#endif
G. Insert the following code segment at line 10: [Conditional("RELEASE")]
Answer: B,F
Explanation:
#if DEBUG: The code in here won't even reach the IL on release. [Conditional("DEBUG")]: This code will reach the IL, however the calls to the method will not execute unless DEBUG is on. http://stackoverflow.com/questions/3788605/if-debug-vs-conditionaldebug