Which two actions should you perform?

You are developing an application that includes the following code segment. (Line numbers are included for reference only.)

image145 - 
Which two actions should you perform?
The GetCustomers() method must meet the following requirements:
• Connect to a Microsoft SQL Server database.
• Populate Customer objects with data from the database.
• Return an IEnumerable<Customer> collection that contains the populated Customer objects.
You need to meet the requirements.
Which two actions should you perform? (Each correct answer presents part of the solution. Choose two.)
A. Insert the following code segment at line 17:
while (sqlDataReader.GetValues())
B. Insert the following code segment at line 14:
sqlConnection.Open();
C. Insert the following code segment at line 14:
sqlConnection.BeginTransaction();
D. Insert the following code segment at line 17:
while (sqlDataReader.Read())
E. Insert the following code segment at line 17:
while (sqlDataReader.NextResult())

Answer: B, D
Explanation:
SqlConnection.Open – Opens a database connection with the property settings specified by the
ConnectionString.
http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlconnection.open.aspx
SqlDataReader.Read – Advances the SqlDataReader to the next record. http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqldatareader.read.aspx

Which code segment should you insert at line 09?

You are developing an application that will use multiple asynchronous tasks to optimize performance.
You create three tasks by using the following code segment. (Line numbers are included for reference only.)

image571 - 
Which code segment should you insert at line 09?
You need to ensure that the ProcessTasks() method waits until all three tasks complete before continuing.
Which code segment should you insert at line 09?
A. Task.WaitFor(3);
B. tasks.Yield();
C. tasks.WaitForCompletion();
D. Task.WaitAll(tasks);

Answer: D

What should you do?

You are adding a public method named UpdateGrade to a public class named ReportCard.
The code region that updates the grade 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 UpdateGrade() method.
What should you do?

image111 - 
What should you do?
A. Option A
B. Option B
C. Option C
D. Option D

Answer: A

Which three actions should you perform in sequence?

DRAG DROP
You are developing an application by using C#. The application will process several objects per second. You need to create a performance counter to analyze the object processing.
Which three actions should you perform in sequence? (To answer, move the appropriate actions from the list of actions to the answer area and arrange them in the correct order.)

image101 - Which three actions should you perform in sequence?

Answer:

image103 - Which three actions should you perform in sequence?
Explanation:
CounterCreationDataCollection counterDataCollection = new CounterCreationDataCollection(); // Box1
// Add the counter. Box 1
CounterCreationData averageCount64 = new CounterCreationData();
averageCount64.CounterType = PerformanceCounterType.AverageCount64;
averageCount64.CounterName = "AverageCounter64Sample";
counterDataCollection.Add(averageCount64);
// Add the base counter.
CounterCreationData averageCount64Base = new CounterCreationData();
averageCount64Base.CounterType = PerformanceCounterType.AverageBase;
averageCount64Base.CounterName = "AverageCounter64SampleBase";
counterDataCollection.Add(averageCount64Base); // Box 2
// Create the category. Box 3
PerformanceCounterCategory.Create("AverageCounter64SampleCategory",
"Demonstrates usage of the AverageCounter64 performance counter type.",
PerformanceCounterCategoryType.SingleInstance, counterDataCollection);

Which two actions should you perform?

You are modifying an application that processes leases.
The following code defines the Lease class. (Line numbers are included for reference only.)

image054 - 
Which two actions should you perform?
Leases are restricted to a maximum term of 5 years. The application must send a notification message if a lease request exceeds 5 years. You need to implement the notification mechanism.
Which two actions should you perform? (Each correct answer presents part of the solution. Choose two.)

image056 - 
Which two actions should you perform?
A. Option A
B. Option B
C. Option C
D. Option D
E. Option E
F. Option F

Answer: A, B

Which line of code should you use?

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?

image672 - 
Which line of code should you use?
A. Option A
B. Option B
C. Option C
D. Option D

Answer: D
Explanation:
If you want to check if it’s an instance of a generic type:
return list.GetType().IsGenericType;
If you want to check if it’s a generic List<T>:
return list.GetType().GetGenericTypeDefinition() == typeof(List<>);
Reference: Testing if object is of generic type in C#
http://stackoverflow.com/questions/982487/testing-if-object-is-of-generic-type-in-c-sharp

What should you include in the code?

You need to write a method that combines an unknown number of strings. The solution must minimize the amount of memory used by the method when the method executes.
What should you include in the code?
A. The String.Concat method
B. The StringBuilder.Append method
C. The + operator
D. The += operator

Answer: D
Explanation:
A: String.Concat Method
Concatenates one or more instances of String, or the String representations of the values of one or more instances of Object.

Which code segment should you insert at line 04?

You are implementing a method named FloorTemperature that performs conversions between value types and reference types.
The following code segment implements the method. (Line numbers are included for reference only.)

image169 - 
Which code segment should you insert at line 04?
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 result = (int)degreesRef;
B. int result = (int)(double)degreesRef;
C. int result = degreesRef;
D. int result = (int)(float)degreesRef;

Answer: D

How should you complete the code?

DRAG DROP
You have the following code.

image608 - How should you complete the code?
You need to return all of the products and their associated categories.
How should you complete the code? To answer, drag the appropriate code elements to the correct targets in the answer area. Each code element 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.

image609 - How should you complete the code?

Answer:

image611 - How should you complete the code?
Explanation:
Example: Join operations create associations between sequences that are not explicitly modeled in the data sources. For example you can perform a join to find all the customers and distributors who have the same location. In LINQ the join clause always works against object collections instead of database tables directly.
C#
var innerJoinQuery =
from cust in customers
join dist in distributors on cust.City equals dist.City
select new { CustomerName = cust.Name, DistributorName = dist.Name };
Reference: https://msdn.microsoft.com/en-us/library/bb397927.aspx
https://msdn.microsoft.com/en-us/library/bb397927.aspx