Q41. - (Topic 2)
You are developing a class named Scorecard. The following code implements the Scorecard class. (Line numbers are included for reference only.)
You create the following unit test method to test the Scorecard class implementation:
You need to ensure that the unit test will pass. What should you do?
A. Option A
B. Option B
C. Option C
D. Option D
Answer: A
Q42. 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:
Q43. - (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.
Q44. - (Topic 1)
You are developing an application by using C#.
You have the following requirements:
Support 32-bit and 64-bit system configurations.
Include pre-processor directives that are specific to the system configuration.
Deploy an application version that includes both system configurations to testers.
Ensure that stack traces include accurate line numbers.
You need to configure the project to avoid changing individual configuration settings every time you deploy the application to testers.
Which two actions should you perform? (Each correct answer presents part of the solution. Choose two.)
A. Update the platform target and conditional compilation symbols for each application configuration.
B. Create two application configurations based on the default Release configuration.
C. Optimize the application through address rebasing in the 64-bit configuration.
D. Create two application configurations based on the default Debug configuration.
Answer: B,D
Q45. - (Topic 2)
You are developing an application that uses several objects. The application includes the following code segment. (Line numbers are included for reference only.)
You need to evaluate whether an object is null. Which code segment should you insert at line 03?
A. Option A
B. Option B
C. Option C
D. Option D
Answer: B
Explanation: Use the == operator to compare values and in this case also use the null literal.
Q46. - (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
Q47. - (Topic 1)
You are developing a method named CreateCounters that will create performance counters for an application. The method includes the following code. (Line numbers are included for reference only.)
You need to ensure that Counter2 is available for use in Windows Performance Monitor (PerfMon).
Which code segment should you insert at line 16?
A. CounterType = PerformanceCounterType.RawBase
B. CounterType = PerformanceCounterType.AverageBase
C. CounterType = PerformanceCounterType.SampleBase
D. CounterType = PerformanceCounterType.CounterMultiBase
Answer: D
Explanation:
PerformanceCounterType.AverageTimer32 - An average counter that measures the time it takes, on average, to complete a process or operation. Counters of this type display a ratio of the total elapsed time of the sample interval to the number of processes or operations completed during that time. This counter type measures time in ticks of the system clock. Formula: ((N 1 -N 0)/F)/(B 1 -B 0), where N 1 and N 0 are performance counter readings, B 1 and B 0 are their corresponding AverageBase values, and F is the number of ticks per second. The value of F is factored into the equation so that the result can be displayed in seconds.
Thus, the numerator represents the numbers of ticks counted during the last sample interval, F represents the frequency of the ticks, and the denominator represents the number of operations completed during the last sample interval. Counters of this type include PhysicalDisk\ Avg. Disk sec/Transfer.
PerformanceCounterType.AverageBase - A base counter that is used in the calculation of time or count averages, such as AverageTimer32 and AverageCount64. Stores the denominator for calculating a counter to present "time per operation" or "count per operation".. http://msdn.microsoft.com/en-us/library/system.diagnostics.performancecountertype.aspx
Q48. DRAG DROP - (Topic 2)
You are developing a C# application. The application includes a class named Rate. The following code segment implements the Rate class:
You define a collection of rates named rateCollection by using the following code segment:
Collection<Rate> rateCollection = new Collection<Rate>() ;
The application receives an XML file that contains rate information in the following format:
You need to parse the XML file and populate the rateCollection collection with Rate objects.
You have the following code: Which code segments should you include in Target 1, Target 2, Target 3 and Target 4 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:
Q49. - (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.
Q50. - (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 3 and the loanAmount value is 9750, the loanRate must be set to 8.25 percent.
You need to adjust the loanRate value to meet the requirements.
What should you do?
A. Replace line 04 with the following code segment: decimal loanRate = 0.0325m;
B. Replace line 17 with the following code segment: interestAmount = loanAmount * 0.0825m * loanTerm;
C. Replace line 15 with the following code segment: loanRate = 0.0825m;
D. Replace line 07 with the following code segment: loanRate = 0.0825m;
Answer: C