Q1. - (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. RemoveMemoryPressure()
B. ReRegisterForFinalize()
C. WaitForFullGCComplete()
D. KeepAlive()
Answer: D
Q2. - (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
Q3. - (Topic 1)
You are developing an application that includes a class named Order. The application will store a collection of Order objects.
The collection must meet the following requirements:
Use strongly typed members.
Process Order objects in first-in-first-out order.
Store values for each Order object.
. Use zero-based indices.
You need to use a collection type that meets the requirements.
Which collection type should you use?
A. Queue<T>
B. SortedList
C. LinkedList<T>
D. HashTable
E. Array<T>
Answer: A
Explanation:
Queues are useful for storing messages in the order they were received for sequential processing. Objects stored in a Queue<T> are inserted at one end and removed from the other. http://msdn.microsoft.com/en-us/library/7977ey2c.aspx
Q4. - (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: * MatchCollection Represents the set of successful matches found by iteratively applying a regular expression pattern to the input string. The collection is immutable (read-only) and has no public constructor. The Regex.Matches method returns a MatchCollection object.
* List<T>.Add Method Adds an object to the end of the List<T>. Incorrect: Not D: ICollection.SyncRoot Property For collections whose underlying store is not publicly available, the expected implementation is to return the current instance. Note that the pointer to the current instance might not be sufficient for collections that wrap other collections; those should return the underlying collection's SyncRoot property.
Q5. - (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
Q6. - (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.)
Q7. - (Topic 1)
You are developing an application. The application converts a Location object to a string by using a method named WriteObject.
The WriteObject() method accepts two parameters, a Location object and an XmlObjectSerializer object.
The application includes the following code. (Line numbers are included for reference only.)
You need to serialize the Location object as XML.
Which code segment should you insert at line 20?
A. new XmlSerializer(typeof(Location))
B. new NetDataContractSerializer()
C. new DataContractJsonSerializer(typeof (Location))
D. new DataContractSerializer(typeof(Location))
Answer: D
Explanation:
The code is using [DataContract] attribute here so need to used DataContractSerializer class.
Q8. - (Topic 1)
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 tog 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: D
Q9. 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 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.)
Answer:
Q10. - (Topic 2)
You need to write a console application that meets the following requirements:
. If the application is compiled in Debug mode, the console output must display Entering debug mode. . If the application is compiled in Release mode, the console output must display Entering release mode.
Which code should you use?
A. Option A
B. Option B
C. Option C
D. Option D
Answer: D
Explanation: Programmatically detecting Release/Debug mode (.NET)
Boolean isDebugMode = false;
#if DEBUG
isDebugMode = true;
#endif
Reference: http://stackoverflow.com/questions/654450/programmatically-detecting-release-debug-mode-net
Q11. HOTSPOT - (Topic 2)
You are building a data access layer in an application that contains the following code:
For each of the following statements, select Yes if the statement is true. Otherwise, select No.
Answer:
Q12. - (Topic 2)
You need to create a method that can be called by using a varying number of parameters.
What should you use?
A. derived classes
B. interface
C. enumeration
D. method overloading
Answer: D
Explanation: Member overloading means creating two or more members on the same type that differ only in the number or type of parameters but have the same name. Overloading is one of the most important techniques for improving usability, productivity, and readability of reusable libraries. Overloading on the number of parameters makes it possible to provide simpler versions of constructors and methods. Overloading on the parameter type makes it possible to use the same member name for members performing identical operations on a selected set of different types.
Q13. - (Topic 1)
You are developing an application by using C#. You provide a public key to the development team during development.
You need to specify that the assembly is not fully signed when it is built.
Which two assembly attributes should you include in the source code? (Each correct answer presents part of the solution. Choose two.)
A. AssemblyKeyNameAttribute
B. ObfuscateAssemblyAttribute
C. AssemblyDelaySignAttribute
D. AssemblyKeyFileAttribute
Answer: C,D
Explanation:
http://msdn.microsoft.com/en-us/library/t07a3dye(v=vs.110).aspx
Q14. HOTSPOT - (Topic 1)
You have the following code: To answer, complete each statement according to the information presented in the code.
Answer:
Q15. DRAG DROP - (Topic 1)
You are developing an application by using C#. The application will output the text string "First Line" followed by the text string "Second Line".
You need to ensure that an empty line separates the text strings.
Which four code segments should you use in sequence? (To answer, move the appropriate code segments to the answer area and arrange them in the correct order.)
Answer: