Q51. 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: 


Q52. - (Topic 2) 

You are creating a class named Loan. 

The Loan class must meet the following requirements: . Include a member that represents the rate for a Loan instance. . Allow external code to assign a value to the rate member. 

Restrict the range of values that can be assigned to the rate member. 

You need to implement the rate member to meet the requirements. 

In which form should you implement the rate member? 

A. public static property 

B. public property 

C. public static field 

D. protected field 

Answer:


Q53. - (Topic 1) 

You are debugging an application that calculates loan interest. The application includes the following code. (Line numbers are included for reference only.) 

You need to ensure that the debugger breaks execution within the CalculateInterest() method when the loanAmount variable is less than or equal to zero in all builds of the application. 

What should you do? 

A. Insert the following code segment at line 03: Trace.Assert(loanAmount > 0); 

B. Insert the following code segment at line 03: Debug.Assert(loanAmount > 0); 

C. Insert the following code segment at line 05: Debug.Write(loanAmount > 0); 

D. Insert the following code segment at line 05: Trace.Write(loanAmount > 0); 

Answer:

Explanation: 

By default, the Debug.Assert method works only in debug builds. Use the Trace.Assert method if you want to do assertions in release builds. For more information, see Assertions in Managed Code. http://msdn.microsoft.com/en-us/library/kssw4w7z.aspx 


Q54. - (Topic 2) 

You have a class named Customer and a variable named customers. 

You need to test whether the customers’ variable is a generic list of Customer objects. Which line of code should you use? 

A. Option A 

B. Option B 

C. Option C 

D. Option D 

Answer:

Explanation: 

http://stackoverflow.com/questions/982487/testing-if-object-is-of-generic-type-in-c-sharp 


Q55. DRAG DROP - (Topic 1) 

You are developing an application that includes a class named Kiosk. The Kiosk class includes a static property named Catalog. The Kiosk class is defined by the following code segment. (Line numbers are included for reference only.) 

You have the following requirements: 

Initialize the _catalog field to a Catalog instance. 

Initialize the _catalog field only once. 

Ensure that the application code acquires a lock only when the _catalog object must be instantiated. 

You need to meet the requirements. 

Which three code segments should you insert in sequence at line 09? (To answer, move the appropriate code segments from the list of code segments to the answer area and arrange them in the correct order.) 

Answer: 


Q56. - (Topic 2) 

You are developing an application that uses a .config file. 

The relevant portion of the .config file is shown as follows: 

You need to ensure that diagnostic data for the application writes to the event log by using the configuration specified in the .config file. 

What should you include in the application code? 

A. Option A 

B. Option B 

C. Option C 

D. Option D 

Answer:

Explanation: Explanation 

http://msdn.microsoft.com/en-us/library/vstudio/system.diagnostics.eventlogtracelistener 

Public static void Main(string[] args) { 

Create a trace listener for the event log. 

EventLogTraceListener myTraceListener = new 

EventLogTraceListener("myEventLogSource"); 

Add the event log trace listener to the collection. 

Trace.Listeners.Add(myTraceListener); 

// Write output to the event log. 

Trace.WriteLine("Test output"); 


Q57. DRAG DROP - (Topic 2) 

You create an assembly named Assembly1.dll. 

You need to ensure that Assembly1.dll can be deployed to the global assembly cache (GAC). 

Which commands should you run? (To answer, drag the appropriate programs to the correct locations. Each program 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: 


Q58. - (Topic 2) 

You have the following code. (Line numbers are included for reference only). 

You need to complete the WriteTextAsync method. The solution must ensure that the code is not blocked while the file is being written. 

Which code should you insert at line 12? 

A. Option A 

B. Option B 

C. Option C 

D. Option D 

Answer:

Explanation: await sourceStream.WriteAsync(encodedText, 0, encodedText.Length); 

The following example has the statement await sourceStream.WriteAsync(encodedText, 0, 

encodedText.Length);, which is a contraction of the following two statements: 

Task theTask = sourceStream.WriteAsync(encodedText, 0, encodedText.Length); 

await theTask; 

Example: The following example writes text to a file. At each await statement, the method immediately exits. When the file I/O is complete, the method resumes at the statement that follows the await statement. Note that the async modifier is in the definition of methods that use the await statement. 

public async void ProcessWrite() 

string filePath = @"temp2.txt"; 

string text = "Hello World\r\n"; 

await WriteTextAsync(filePath, text); 

private async Task WriteTextAsync(string filePath, string text) 

byte[] encodedText = Encoding.Unicode.GetBytes(text); 

using (FileStream sourceStream = new FileStream(filePath, 

FileMode.Append, FileAccess.Write, FileShare.None, 

bufferSize: 4096, useAsync: true)) 

await sourceStream.WriteAsync(encodedText, 0, encodedText.Length); 

}; 

Reference: Using Async for File Access (C# and Visual Basic) 

https://msdn.microsoft.com/en-us/library/jj155757.aspx 


Q59. - (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 assembly attributes. 

B. Use the csc.exe /target:Library option when building the application. 

C. Use the xsd.exe command-line tool. 

D. Use the EdmGen.exe command-line tool. 

Answer:

Explanation: The Windows Software Development Kit (SDK) provides several ways to sign an assembly with a strong name: 

* (A) 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 the Assembly Linker (Al.exe) provided by the Windows SDK. 

* 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.) 


Q60. HOTSPOT - (Topic 1) 

You are developing an application that includes a Windows Communication Foundation (WCF) service. The service includes a custom TraceSource object named ts and a method named DoWork. The application must meet the following requirements: 

. Collect trace information when the DoWork() method executes. . Group all traces for a single execution of the DoWork() method as an activity that can be viewed in the WCF Service Trace Viewer Tool. 

You need to ensure that the application meets the requirements. 

How should you complete the relevant code? (To answer, select the correct code segment from each drop-down list in the answer area.) 

Answer: