You are implementing a method named FloorTemperature that performs conversions between value types and reference types. The following code segment implements the method. (Line numbers are included for reference only.)
Answer : D
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?
Answer : B
You are developing an application that uses structured exception handling. The application includes a class named Logger. The Logger class implements a method named Log by using the following code segment: public static void Log(Exception ex) { }
You have the following requirements:
-> Log all exceptions by using the Log() method of the Logger class.
-> Rethrow the original exception, including the entire exception stack.
You need to meet the requirements. Which code segment should you use?
Answer : D
Explanation:
Once an exception is thrown, part of the information it carries is the stack trace. The stack trace is a list of the method call hierarchy that starts with the method that throws the exception and ends with the method that catches the exception. If an exception is re-thrown by specifying the exception in the throw statement, the stack trace is restarted at the current method and the list of method calls between the original method that threw the exception and the current method is lost. To keep the original stack trace information with the exception, use the throw statement without specifying the exception.
References:
https://docs.microsoft.com/en-us/previous-versions/visualstudio/visual-studio-2012/ms182363(v=vs.110)
DRAG DROP -
You are developing an application that will include a method named GetData. The GetData() method will retrieve several lines of data from a web service by using a System.IO.StreamReader object.
You have the following requirements:
-> The GetData() method must return a string value that contains the entire response from the web service.
-> The application must remain responsive while the GetData() method runs.
You need to implement the GetData() method.
How should you complete the relevant code? (To answer, drag the appropriate objects to the correct locations in the answer area. Each object 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.)
Select and Place:
Answer :
You are developing an application that includes a class named BookTracker for tracking library books. The application includes the following code segment. (Line numbers are included for reference only.)
Answer : A
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?
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.
References:
http://msdn.microsoft.com/en-us/library/dd270696.aspx
You have the following code. (Line numbers are included for reference only.)
Answer : B
References:
https://www.dotnetperls.com/divide
DRAG DROP -
You have the following code:
Answer :
References:
https://docs.microsoft.com/en-us/dotnet/framework/wcf/feature-details/how-to-serialize-and-deserialize-json-data
HOTSPOT -
You are developing a method named Method1 for a class named Class1. and returns to a decimal value.
You need to ensure that calls to Method1 support being executed on separate threads.
How should you complete the method signature? To answer, select the appropriate options in the answer area.
NOTE: Each correct selection is worth one point.
Hot Area:
Answer :
Reference:
https://docs.microsoft.com/en-us/dotnet/csharp/async
You are creating an application that manages information about your company's products. The application includes a class named Product and a method named
.
Save -
The Save() method must be strongly typed. It must allow only types inherited from the Product class that use a constructor that accepts no parameters.
You need to implement the Save() method.
Which code segment should you use?
Answer : D
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.)
Answer : EF
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?
Answer : D
You have the following C# code.
StringBuilder sb = new StringBuilder(reallyLongString);
The reallyLongString variable is a string in which a very long string is stored.
You need to identify whether a string stored in an object named StringToFind is within the StringBuilder sb object.
Which code should you use?
Answer : A
References:
https://docs.microsoft.com/en-us/dotnet/api/system.text.stringbuilder.equals?view=netframework-
4.7.2#System_Text_StringBuilder_Equals_System_Text_StringBuilder_
DRAG DROP -
You are developing an application by using C#. The application will process several objects per second.
You need to create a performance counter to analyze the object processing.
Which three actions should you perform in sequence? (To answer, move the appropriate actions from the list of actions to the answer area and arrange them in the correct order.)
Select and Place:
Answer :
Explanation:
Note:
Example:
CounterCreationDataCollection counterDataCollection = new CounterCreationDataCollection(); // Box1
// Add the counter. Box 1
CounterCreationData averageCount64 = new CounterCreationData(); averageCount64.CounterType = PerformanceCounterType.AverageCount64; averageCount64.CounterName = "AverageCounter64Sample"; counterDataCollection.Add(averageCount64);
// Add the base counter.
CounterCreationData averageCount64Base = new CounterCreationData(); averageCount64Base.CounterType = PerformanceCounterType.AverageBase; averageCount64Base.CounterName = "AverageCounter64SampleBase"; counterDataCollection.Add(averageCount64Base); // Box 2
// Create the category. Box 3
PerformanceCounterCategory.Create("AverageCounter64SampleCategory",
"Demonstrates usage of the AverageCounter64 performance counter type.",
PerformanceCounterCategoryType.SingleInstance, counterDataCollection);
You are developing an application. The application calls a method that returns an array of integers named customerIds.
You define an integer variable named customerIdToRemove and assign a value to it. You declare an array named filteredCustomerIds.
You have the following requirements.
-> Remove duplicate integers from the customerIds array.
-> Sort the array in order from the highest value to the lowest value.
-> Remove the integer value stored in the customerIdToRemove variable from the customerIds array.
You need to create a LINQ query to meet the requirements.
Which code segment should you use?
Answer : C