You are developing an application that will manage customer records. The application includes a method named FindCustomer.
Users must be able to locate customer records by using the customer identifier or customer name.
You need to implement the FindCustomer() method to meet the requirement.
Which two sets of method signatures can you use to achieve this goal? (Each correct answer presents a complete solution. Choose two.)
Answer : B, D
You need to write a method that retrieves data from a Microsoft Access 2013 database. The method must meet the following requirements:
* Be read-only.
* Be able to use the data before the entire data set is retrieved.
* Minimize the amount of system overhead and the amount of memory usage.
Which type of object should you use in the method?
Answer : A
DbDataReader Class
Reads a forward-only stream of rows from a data source.
https://msdn.microsoft.com/en-us/library/system.data.common.dbdatareader(v=vs.110).aspx
You are developing an application that includes a class named Customer and a generic list of customers. The following code segment declares the list of customers:
List
You populate the customersList object with several hundred Customer objects.
The application must display the data for five Customer objects at a time.
You need to create a method that will return the correct number of Customer objects.
Which code segment should you use?
Answer : A
Note: Something wrong with question as the question is about LINQ, while the answers are about class definitions (and not LINQ method definitions).
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?
Answer : B
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.
Incorrect answers:
Not A: TRACE is used to enable tracing. It is not used for conditional compilation.
https://msdn.microsoft.com/en-us/library/64yxa344(v=vs.110).aspx
You are implementing a method named ProcessData that performs a long-running task. The ProcessData() method has the following method signature:
public void ProcessData(List
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 ProcessData() method performs the required actions.
Which code segment should you use in the method body?
Answer : C
The CancellationToken.ThrowIfCancellationRequested method throws a OperationCanceledException if this token has had cancellation requested.
This method provides functionality equivalent to:
C#
if (token.IsCancellationRequested)
throw new OperationCanceledException(token);
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.)
Answer : A, B
* 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>.
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?
Answer : C
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