Q1. 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:
Q2. - (Topic 1)
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?
A. Create a task within the operation, and set the Task.StartOnError property to true.
B. Create a TaskFactory object and call the ContinueWhenAll() method of the object.
C. Create a task by calling the Task.ContinueWith() method.
D. Use the TaskScheduler class to create a task and call the TryExecuteTask() method on the class.
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. http://msdn.microsoft.com/en-us/library/dd270696.aspx
Q3. 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:
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 developing an assembly.
You plan to sign the assembly when the assembly is developed.
You need to reserve space in the assembly for the signature.
What should you do?
A. Run the Assembly Linker tool from the Windows Software Development Kit (Windows SDK).
B. Run the Strong Name tool from the Windows Software Development Kit (Windows SDK).
C. Add the AssemblySignatureKeyAttribute attribute the assembly.
D. Add the AssemblyDelaySignAttribute attribute to the assembly.
Answer: D
Q6. - (Topic 1)
You are implementing a method named Calculate that performs conversions between value types and reference types. The following code segment implements the method. (Line numbers are included for reference only.)
You need to ensure that the application does not throw exceptions on invalid conversions.
Which code segment should you insert at line 04?
A. int balance = (int) (float)amountRef;
B. int balance = (int)amountRef;
C. int balance = amountRef;
D. int balance = (int) (double) amountRef;
Answer: A
Q7. - (Topic 2)
You are implementing a method named GetValidPhoneNumbers. The GetValidPhoneNumbers() method processes a list of string values that represent phone numbers.
The GetValidPhoneNumbers() method must return only phone numbers that are in a valid format.
You need to implement the GetValidPhoneNumbers() method.
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,B
Explanation: * Regex.Matches Searches an input string for all occurrences of a regular expression and returns all the matches.
* 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>.
Q8. - (Topic 1)
You are developing an application that includes the following code segment. (Line numbers are included for reference only.)
You need to ensure that the application accepts only integer input and prompts the user each time non-integer input is entered.
Which code segment should you add at line 19?
A. If (!int.TryParse(sLine, out number))
B. If ((number = Int32.Parse(sLine)) == Single.NaN)
C. If ((number = int.Parse(sLine)) > Int32.MaxValue)
D. If (Int32.TryParse(sLine, out number))
Answer: A
Explanation:
B and C will throw exception when user enters non-integer value. D is exactly the opposite what we want to achieve.
Int32.TryParse - Converts the string representation of a number to its 32-bit signed integer equivalent. A return value indicates whether the conversion succeeded. http://msdn.microsoft.com/en-us/library/f02979c7.aspx
Q9. DRAG DROP - (Topic 1)
You are implementing a method that creates an instance of a class named User. The User class contains a public event named Renamed. The following code segment defines the Renamed event:
Public event EventHandler<RenameEventArgs> Renamed;
You need to create an event handler for the Renamed event by using a lambda expression.
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:
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 the csc.exe /target:Library option when building the application.
B. Use the AL.exe command-line tool.
C. Use the aspnet_regiis.exe command-line tool.
D. Use the EdmGen.exe command-line tool.
Answer: B
Explanation: The Windows Software Development Kit (SDK) provides several ways to sign an assembly with a strong name:
* Using the Assembly Linker (Al.exe) provided by the Windows SDK.
* 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 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.)
Note:
* A strong name consists of the assembly's identity—it’s simple text name, version number, and culture information (if provided)—plus a public key and a digital signature. It is generated from an assembly file (the file that contains the assembly manifest, which in turn contains the names and hashes of all the files that make up the assembly), using the corresponding private key. Microsoft. Visual Studio. .NET and other development tools provided in the .NET Framework SDK can assign strong names to an assembly.
Assemblies with the same strong name are expected to be identical.