Q1. DRAG DROP - (Topic 1)
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.)
Answer:
Q2. HOTSPOT - (Topic 2)
You define a class by using the following code: You write the following code for a method (line numbers are included for reference only):
To answer, complete each statement according to the information presented in the code.
Answer:
Q3. DRAG DROP - (Topic 1)
You are developing an application by using C#. The application includes an array of decimal values named loanAmounts. You are developing a LINQ query to return the values from the array.
The query must return decimal values that are evenly divisible by two. The values must be sorted from the lowest value to the highest value.
You need to ensure that the query correctly returns the decimal values.
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:
Q4. - (Topic 1)
You are developing an application by using C#. The application includes the following code segment. (Line numbers are included for reference only.)
The DoWork() method must throw an InvalidCastException exception if the obj object is not of type IDataContainer when accessing the Data property.
You need to meet the requirements. Which code segment should you insert at line 07?
A. var dataContainer = (IDataContainer) obj;
B. var dataContainer = obj as IDataContainer;
C. var dataContainer = obj is IDataContainer;
D. dynamic dataContainer = obj;
Answer: A
Explanation:
http://msdn.microsoft.com/en-us/library/ms173105.aspx
Q5. - (Topic 1)
You are developing an application. The application includes classes named Mammal and Animal and an interface named IAnimal.
The Mammal class must meet the following requirements: . It must either inherit from the Animal class or implement the IAnimal interface. . It must be inheritable by other classes in the application. You need to ensure that the Mammal class meets the requirements.
Which two code segments can you use 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
Explanation:
When applied to a class, the sealed modifier prevents other classes from inheriting from it. http://msdn.microsoft.com/en-us/library/88c54tsw(v=vs.110).aspx
Q6. DRAG DROP - (Topic 1)
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 first line of the 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.)
Answer:
Q7. - (Topic 1)
You are developing an assembly that will be used by multiple applications.
You need to install the assembly in the Global Assembly Cache (GAC).
Which two actions can you perform to achieve this goal? (Each correct answer presents a complete solution. Choose two.)
A. Use the Assembly Registration tool (regasm.exe) to register the assembly and to copy the assembly to the GAC.
B. Use the Strong Name tool (sn.exe) to copy the assembly into the GAC.
C. Use Microsoft Register Server (regsvr32.exe) to add the assembly to the GAC.
D. Use the Global Assembly Cache tool (gacutil.exe) to add the assembly to the GAC.
E. Use Windows Installer 2.0 to add the assembly to the GAC.
Answer: D,E
Explanation:
There are two ways to deploy an assembly into the global assembly cache:
Use an installer designed to work with the global assembly cache. This is the preferred option for installing assemblies into the global assembly cache.
Use a developer tool called the Global Assembly Cache tool (Gacutil.exe), provided by the
Windows
Software Development Kit (SDK).
Note:
In deployment scenarios, use Windows Installer 2.0 to install assemblies into the global assembly cache. Use the Global Assembly Cache tool only in development scenarios, because it does not provide assembly reference counting and other features provided when using the Windows Installer.
http://msdn.microsoft.com/en-us/library/yf1d93sz%28v=vs.110%29.aspx
Q8. - (Topic 2)
You are developing a class named Account that will be used by several applications. The applications that will consume the Account class will make asynchronous calls to the Account class to execute several different methods.
You need to ensure that only one call to the methods is executed at a time.
Which keyword should you use?
A. sealed
B. protected
C. checked
D. lock
Answer: D
Q9. - (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
Q10. - (Topic 2)
You are developing a C# application. The application references and calls a RESTful web service named EmployeeService. The EmployeeService web service includes a method named GetEmployee, which accepts an employee ID as a parameter. The web service returns the following JSON data from the method.
{"Id":1,"Name":"David Jones">
The following code segment invokes the service and stores the result:
You need to convert the returned JSON data to an Employee object for use in the application.
Which code segment should you use?
A. Option A
B. Option B
C. Option C
D. Option D
Answer: C
Q11. - (Topic 2)
You write the following method (line numbers are included for reference only):
You need to ensure that the method extracts a list of URLs that match the following pattern: @http://(www\.)?([^\.]+)\.com;
Which code should you insert at line 07?
A. Option A
B. Option B
C. Option C
D. Option D
Answer: A
Explanation: The MatchCollection.GetEnumerator method returns an enumerator that
iterates through a collection.
Note:
The MatchCollection Class represents the set of successful matches found by iteratively
applying a regular expression pattern to the input string.
Reference: MatchCollection.GetEnumerator Method
https://msdn.microsoft.com/en-us/library/system.text.regularexpressions.matchcollection.getenumerator(v=vs.110).aspx
Q12. DRAG DROP - (Topic 2)
You are creating a method that saves information to a database.
You have a static class named LogHelper. LogHelper has a method named Log to log the exception.
You need to use the LogHelper Log method to log the exception raised by the database server. The solution must ensure that the exception can be caught by the calling method, while preserving the original stack trace.
How should you write the catch block? (Develop the solution by selecting and ordering the required code snippets. You may not need all of the code snippets.)
Answer:
Q13. - (Topic 1)
You are developing an application that uses structured exception handling. The application includes a class named ExceptionLogger.
The ExceptionLogger class implements a method named LogException by using the following code segment:
public static void LogException(Exception ex)
You have the following requirements: . Log all exceptions by using the LogException() method of the ExceptionLogger class. . Rethrow the original exception, including the entire exception stack. You need to meet the requirements.
Which code segment should you use?
A. Option A
B. Option B
C. Option C
D. Option D
Answer: A
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.
http://msdn.microsoft.com/en-us/library/ms182363(v=vs.110).aspx
Q14. - (Topic 2)
You are developing an application that will parse a large amount of text.
You need to parse the text into separate lines and minimize memory use while processing data.
Which object type should you use?
A. DataContractSerializer
B. StringBuilder
C. StringReader
D. JsonSerializer
Answer: C
Q15. - (Topic 2)
You are implementing a method named ProcessReports that performs a long-running task. The ProcessReports() method has the following method signature:
public void ProcessReports(List<decimal> values,CancellationTokenSource cts, CancellationToken ct)
If the calling code requests cancellation, the method must perform the following actions:
. Cancel the long-running task.
. Set the task status to TaskStatus.Canceled.
You need to ensure that the ProcessReports() method performs the required actions.
Which code segment should you use in the method body?
A. if (ct.IsCancellationRequested) return;
B. ct.ThrowIfCancellationRequested() ;
C. cts.Cancel();
D. throw new AggregateException();
Answer: B