Q1. 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:
Q2. - (Topic 1)
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.)
You need to add a user to the BookTracker instance. What should you do? A. Option A
B. Option B
C. Option C
D. Option D
Answer: B
Q3. - (Topic 2)
You are developing an application.
The application contains the following code segment (line numbers are included for reference only):
When you run the code, you receive the following error message: "Cannot implicitly convert type 'object'' to 'int'. An explicit conversion exists (are you missing a cast?)."
You need to ensure that the code can be compiled.
Which code should you use to replace line 05?
A. var2 = arrayl[0] is int;
B. var2 = ((List<int>)arrayl) [0];
C. var2 = arrayl[0].Equals(typeof(int));
D. var2 = (int) arrayl [0];
Answer: D
Q4. HOTSPOT - (Topic 2)
You have the following code (line numbers are included for reference only):
To answer, complete each statement according to the information presented in the code.
Answer:
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 1)
You are creating a console application named App1.
App1 retrieves data from the Internet by using JavaScript Object Notation (JSON).
You are developing the following code segment (line numbers are included for reference only):
You need to ensure that the code validates the JSON string.
Which code should you insert at line 03?
A. DataContractSerializer serializer = new DataContractSerializer();
B. var serializer = new DataContractSerializer();
C. XmlSerlalizer serializer = new XmlSerlalizer();
D. var serializer = new JavaScriptSerializer();
Answer: D
Explanation: The JavaScriptSerializer Class Provides serialization and deserialization functionality for AJAX-enabled applications.
The JavaScriptSerializer class is used internally by the asynchronous communication layer to serialize and deserialize the data that is passed between the browser and the Web server. You cannot access that instance of the serializer. However, this class exposes a public API. Therefore, you can use the class when you want to work with JavaScript Object Notation (JSON) in managed code.
Q7. DRAG DROP - (Topic 1)
You are developing a class named ExtensionMethods.
You need to ensure that the ExtensionMethods class implements the IsEmail() method on string objects.
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:
Q8. - (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
Q9. - (Topic 2)
An application is throwing unhandled NullReferenceException and FormatException errors. The stack trace shows that the exceptions occur in the GetWebResult() method.
The application includes the following code to parse XML data retrieved from a web service. (Line numbers are included for reference only.)
You need to handle the exceptions without interfering with the existing error-handling infrastructure.
Which two actions should you perform? (Each correct answer presents part of the solution. Choose two.)
A. Option A
B. Option B
C. Option C
D. Option D
Answer: A,C
Explanation: A: The TryParse method is like the Parse method, except the TryParse method does not throw an exception if the conversion fails. It eliminates the need to use exception handling to test for a FormatException in the event that s is invalid and cannot be successfully parsed.
C: UnhandledException event handler If the UnhandledException event is handled in the default application domain, it is raised there for any unhandled exception in any thread, no matter what application domain the thread started in. If the thread started in an application domain that has an event handler for UnhandledException, the event is raised in that application domain.
Q10. DRAG DROP - (Topic 2)
You have an application that uses paging. Each page displays 10 items from a list.
You need to display the third page. (Develop the solution by selecting and ordering the required code snippets. You may not need all of the code snippets.)
Answer:
Q11. HOTSPOT - (Topic 2)
You have the following code:
For each of the following statements, select Yes if the statement is true. Otherwise, select No.
Answer:
Q12. - (Topic 1)
You are developing an application that will convert data into multiple output formats.
The application includes the following code. (Line numbers are included for reference only.)
You are developing a code segment that will produce tab-delimited output. All output routines implement the following interface:
You need to minimize the completion time of the GetOutput() method. Which code segment should you insert at line 06?
A. Option A
B. Option B
C. Option C
D. Option D
Answer: B
Explanation:
A String object concatenation operation always creates a new object from the existing string and the new data. A StringBuilder object maintains a buffer to accommodate the concatenation of new data. New data is appended to the buffer if room is available; otherwise, a new, larger buffer is allocated, data from the original buffer is copied to the new buffer, and the new data is then appended to the new buffer. The performance of a concatenation operation for a String or StringBuilder object depends on the frequency of memory allocations. A String concatenation operation always allocates memory, whereas a StringBuilder concatenation operation allocates memory only if the StringBuilder object buffer is too small to accommodate the new data. Use the String class if you are concatenating a fixed number of String objects. In that case, the compiler may even combine individual concatenation operations into a single operation. Use a StringBuilder object if you are concatenating an arbitrary number of strings; for example, if you're using a loop to concatenate a random number of strings of user input.
http://msdn.microsoft.com/en-us/library/system.text.stringbuilder(v=vs.110).aspx
Q13. - (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. Decorate the code by using the [DebuggerDisplay("Mydebug")] attribute.
C. Configure the Define DEBUG constant setting in Microsoft Visual Studio.
D. Disable the strong-name bypass feature of Microsoft .NET Framework in the registry.
Answer: C
Explanation: Use one debug version to connect to the development database, and a standard version to connect to the live database.
Q14. - (Topic 2)
You have a class named Customer and a variable named customers.
You need to test whether the customers’ variable is a generic list of Customer objects. Which line of code should you use?
A. Option A
B. Option B
C. Option C
D. Option D
Answer: D
Explanation:
http://stackoverflow.com/questions/982487/testing-if-object-is-of-generic-type-in-c-sharp
Q15. - (Topic 1)
You are developing an application that will transmit large amounts of data between a client computer and a server.
You need to ensure the validity of the data by using a cryptographic hashing algorithm.
Which algorithm should you use?
A. HMACSHA256
B. RNGCryptoServiceProvider
C. DES
D. Aes
Answer: A
Explanation:
The .NET Framework provides the following classes that implement hashing algorithms:
HMACSHA1.
MACTripleDES.
MD5CryptoServiceProvider.
RIPEMD160.
SHA1Managed.
SHA256Managed.
SHA384Managed.
SHA512Managed.
HMAC variants of all of the Secure Hash Algorithm (SHA), Message Digest 5 (MD5), and
RIPEMD-160 algorithms.
CryptoServiceProvider implementations (managed code wrappers) of all the SHA
algorithms.
Cryptography Next Generation (CNG) implementations of all the MD5 and SHA algorithms.
http://msdn.microsoft.com/en-us/library/92f9ye3s.aspx#hash_values