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?
Explanation: Queues are useful for storing messages in the order they were received for sequential processing. Objects stored in a Queue are inserted at one end and removed from the other. http://msdn.microsoft.com/en-us/library/7977ey2c.aspx
You are developing an application. The application calls a method that returns an array of integers named employeelds. You define an integer variable named employeeldToRemove and assign a value to it. You declare an array named filteredEmployeelds.
You have the following requirements:
Remove duplicate integers from the employeelds array.
Sort the array in order from the highest value to the lowest value.
Remove the integer value stored in the employeeldToRemove variable from the employeelds array.
You need to create a LINQ query to meet the requirements. Which code segment should you use?
A. Option A B. Option B C. Option C D. Option D Answer: C
You are developing an application that uses the Microsoft ADO.NET Entity Framework to retrieve order information from a Microsoft SQL Server database. The application includes the following code. (Line numbers are included for reference only.)
The application must meet the following requirements:
Return only orders that have an OrderDate value other than null.
Return only orders that were placed in the year specified in the OrderDate property or in a later year.
You need to ensure that the application meets the requirements.
Which code segment should you insert at line 08?
A. Where order. OrderDate Value = null&& Order. OrderDate Value Year > = year B. Where order. OrderDate Value = = null&& order. OrderDate Value Year = = year C. Where order. OrderDate. HasValue && Order. OrderDate Value.Year = = year D. Where order. OrderDate Value Year = = year
You are developing an application. The application includes a method named ReadFile that reads data from a file. The ReadFile() method must meet the following requirements:
It must not make changes to the data file.
It must allow other processes to access the data file.
It must not throw an exception if the application attempts to open a data file that does not exist.
You need to implement the Read File () method. Which code segment should you use?
A. var fs = File.Open(Filename, FileMode.OpenOrCreate, FileAccess. Read, FileShare. ReadWrite); B. var fs = File.Open(Filename, FileMode.Open, FileAccess.Read, FileShare. ReadWrite);
C. var fs = File.Open(Filename, FileMode.OpenOrCreate, File:Access. Read, FileShare.Write); D. var fs = Fille. ReadAllLines(Filename);
E. var fs = File. ReadAll Bytes(Filename);
FileMode.OpenOrcreate - Specifies that the operating system should open a file if it exists; otherwise, a new file should be created. If the file is opened with FileAccess. Read, FileIOPermissionAccess. Read permission is required. If the file access is FileAccess. Write, FileIOPermissionAccess. Write permission is required. If the file is opened with FileAccess. ReadWrite, both FileIOPermissionAccess. Read and FileIOPermissionAccess Write permissions are required.
FileShare. ReadWrite - Allows subsequent opening of the file for reading or writing...if this flag is not specified, any request to open the file for reading or writing (by this process or another process) will fail until the file is closed. However, even if this flag is specified, additional permissions might still be needed to access the file.
You are Creating an application that manages information about ZOO animals. The application includes a class named Animal and a method named Save.
The Save() method must be strongly typed. It must allow only types inherited from the Animal class that uses a constructor that accepts no parameters.
You need to implement the Save() method. Which code segment should you use?
A. Option A B. Option B C. Option C D. Option D Answer: C Explanation:
When you define a generic class, you can apply restrictions to the kinds of types that client Code can use for type arguments when it instantiates your class. If client Code tries to instantiate your class by using a type that is not allowed by a constraint, the result is a compile- time error. These restrictions are called constraints. Constraints are specified by using the where contextual keyword.
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. intbalance = (int) (float)amountRef;
B. int balance = (int)amountRef;
C. intbalance = amountRef;
D. intbalance = (int) (double) amountRef; Answer: A
You are Creating a class named Employee. The class exposes a string property named EmployeeType. The following code segment defines the Employee class. (Line numbers are included for reference only.)
The EmployeeType property value must be accessed and modified only by Code within the Employee class or within a class derived from the Employee class.
You need to ensure that the implementation of the EmployeeType property meets the requirements. Which two actions should you perform?(Each correct answer represents part of the complete solution. Choose two.)
A. Replace line 05 with the following code segment: protected get;
B. Replace line 06 with the following code segment: private set;
C. Replace line 03 with the following code segment: public string EmployeeType
D. Replace line 05 with the following code segment: private get;
E. Replace line 03 with the following code segment: protected string EmployeeType F. Replace line 06 with the following code segment: protected set;
Answer: B, E
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 TaskCompletionSource&T- object and call the TrySetException() method of the object.
B. Create a task by calling the Task.ContinueWith() method.
C. Examine the Task. Status property immediately after the call to the Task. Run() method.
D. Create a task inside the existing Task. Run() method by using the Attached ToParent option. Answer: B
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.
You are adding a public method named UpdateScore to a public class named ScoreCard. The code region that updates the score field must meet the following requirements:
It must be accessed by only one thread at a time.
It must not be vulnerable to a deadlock situation. You need to implement the UpdateScore() method. What should you do?
A. Option A
B. Option B
C. Option C
D. Option D