Q1. - (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
Q2. - (Topic 2)
You have the following code: You need to retrieve all of the numbers from the items variable that are greater than 80. Which code should you use?
A. Option A
B. Option B
C. Option C
D. Option D
Answer: A
Q3. - (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. ReRegisterForFinalize()
B. SuppressFinalize()
C. Collect()
D. WaitForFullGCApproach()
Answer: B
Q4. DRAG DROP - (Topic 1)
You are developing an application that implements a set of custom exception types. You declare the custom exception types by using the following code segments:
The application includes a function named DoWork that throws .NET Framework exceptions and custom exceptions.
The application contains only the following logging methods:
The application must meet the following requirements:
. When AdventureWorksValidationException exceptions are caught, log the information by using the static void Log (AdventureWorksValidationException ex) method.
. When AdventureWorksDbException or other AdventureWorksException exceptions are caught, log the information by using the static void I oq( AdventureWorksException ex) method.
You need to meet the requirements.
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:
Q5. - (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
Q6. - (Topic 1)
You are developing a C# application that includes a class named Product. The following code segment defines the Product class:
You implement System.ComponentModel.DataAnnotations.IValidateableObject interface to provide a way to validate the Product object.
The Product object has the following requirements:
. The Id property must have a value greater than zero.
. The Name property must have a value other than empty or null. You need to validate the Product object. Which code segment should you use?
A. Option A
B. Option B
C. Option C
D. Option D
Answer: B
Q7. DRAG DROP - (Topic 1)
You are developing an application that includes a class named Warehouse. The Warehouse class includes a static property named Inventory- The Warehouse class is defined by the following code segment. (Line numbers are included for reference only.)
You have the following requirements:
Initialize the _inventory field to an Inventory instance.
Initialize the _inventory field only once.
Ensure that the application code acquires a lock only when the _inventory 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:
Q8. 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:
Q9. - (Topic 2)
You are creating an application that reads from a database.
You need to use different databases during the development phase and the testing phase by using conditional compilation techniques.
What should you do?
A. Configure the Define TRACE constant setting in Microsoft Visual Studio.
B. Specify the /define compiler option.
C. Run the Assembly Linker tool from the Windows Software Development Kit (Windows SDK).
D. Decorate the code by using the [assembly:AssemblyDelaySignAttribute(true)] attribute.
Answer: B
Explanation: You can specify the compiler settings for your application in several ways:
* The property pages
* The command line
* #CONST (for Visual Basic) and #define (for C#)
Note: You can have either the Trace or Debug conditional attribute turned on for a build, or both, or neither. Thus, there are four types of build: Debug, Trace, both, or neither. Some release builds for production deployment might contain neither; most debugging builds contain both.
Reference: How to: Compile Conditionally with Trace and Debug
https://msdn.microsoft.com/en-us/library/64yxa344(v=vs.110).aspx
Q10. - (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: A
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.)
Q11. - (Topic 2)
You are modifying an existing application that manages employee payroll. The application includes a class named PayrollProcessor. The PayrollProcessor class connects to a payroll database and processes batches of paychecks once a week.
You need to ensure that the PayrollProcessor class supports iteration and releases database connections after the batch processing completes.
Which two interfaces should you implement? (Each correct answer presents part of the complete solution. Choose two.)
A. IEquatable
B. IEnumerable
C. IDisposable
D. IComparable
Answer: B,C
Explanation: IEnumerable IDisposable Interface Exposes an enumerator, which supports a simple iteration over a non-generic collection.
Defines a method to release allocated resources.
The primary use of this interface is to release unmanaged resources.
Q12. - (Topic 2)
You are developing a C# application. The application includes the following code segment, (Line numbers are included for reference only.)
The application fails at line 17 with the following error message: "An item with the same key has already been added."
You need to resolve the error.
Which code segment should you insert at line 16?
A. Option A
B. Option B
C. Option C
D. Option D
Answer: A
Q13. - (Topic 1)
You are creating a console application by using C#.
You need to access the application assembly.
Which code segment should you use?
A. Assembly.GetAssembly(this);
B. this.GetType();
C. Assembly.Load();
D. Assembly.GetExecutingAssembly();
Answer: D
Explanation:
Assembly.GetExecutingAssembly - Gets the assembly that contains the code that is currently executing. http://msdn.microsoft.com/en-us/library/system.reflection.assembly.getexecutingassembly(v=vs.110).aspx
Assembly.GetAssembly - Gets the currently loaded assembly in which the specified class is defined. http://msdn.microsoft.com/en-us/library/system.reflection.assembly.getassembly.aspx
Q14. DRAG DROP - (Topic 1)
You develop an application that displays information from log files when errors occur. The application will prompt the user to create an error report that sends details about the error and the session to the administrator.
When a user opens a log file by using the application, the application throws an exception and closes.
The application must preserve the original stack trace information when an exception occurs during this process.
You need to implement the method that reads the log files.
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:
Q15. HOTSPOT - (Topic 2)
You have an existing order processing system that accepts .xml files,
The following code shows an example of a properly formatted order in XML:
You create the following class that will be serialized:
For each of the following properties, select Yes if the property is serialized according to the defined schema. Otherwise, select No.
Answer: