Q11. - (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
Q12. - (Topic 1)
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 year parameter.
You need to ensure that the application meets the requirements. Which code segment should you insert at line 08?
A. Option A
B. Option B
C. Option C
D. Option D
Answer: B
Q13. - (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. ECDsa
B. RNGCryptoServiceProvider
C. Rfc2898DeriveBytes
D. HMACSHA512
Answer: D
Q14. - (Topic 2)
You have the following code (line numbers are included for reference only):
You need to ensure that new instances of Connection can be created only by other classes by calling the Create method. The solution must allow classes to inherit from Connection.
What should you do?
A. Option A
B. Option B
C. Option C
D. Option D
Answer: B
Explanation: The following list provides the main features of a static class:
* Contains only static members.
* Cannot be instantiated.
* Is sealed.
* Cannot contain Instance Constructors.
Creating a static class is therefore basically the same as creating a class that contains only static members and a private constructor. A private constructor prevents the class from being instantiated.
Reference: Static Classes and Static Class Members (C# Programming Guide)
https://msdn.microsoft.com/en-us/library/79b3xss3.aspx
Q15. - (Topic 1)
You are debugging an application that calculates loan interest. The application includes the following code. (Line numbers are included for reference only.)
You have the following requirements:
. The debugger must break execution within the Calculatelnterest() method when the loanAmount variable is less than or equal to zero. . The release version of the code must not be impacted by any changes.
You need to meet the requirements.
What should you do?
A. Insert the following code segment at tine 05: Debug.Write(loanAmount > 0);
B. Insert the following code segment at line 05: Trace.Write(loanAmount > 0);
C. Insert the following code segment at line 03: Debug.Assert(loanAmount > 0);
D. Insert the following code segment at line 03: Trace.Assert(loanAmount > 0);
Answer: C
Explanation:
By default, the Debug.Assert method works only in debug builds. Use the Trace.Assert method if you want to do assertions in release builds. For more information, see Assertions in Managed Code. http://msdn.microsoft.com/en-us/library/kssw4w7z.aspx
Q16. - (Topic 2)
You are developing an application that includes a class named Employee and a generic list
of employees. The following code segment declares the list of employees:
List<Employee> employeesList = new List<Employee>();
You populate the employeesList object with several hundred Employee objects.
The application must display the data for five Employee objects at a time.
You need to create a method that will return the correct number of Employee objects.
Which code segment should you use?
A. Option A
B. Option B
C. Option C
D. Option D
Answer: B
Q17. - (Topic 2)
You are modifying an existing application.
The application includes a Loan class and a Customer class. The following code segment defines the classes.
You populate a collection named customer-Collection with Customer and Loan objects by using the following code segment:
You create a largeCustomerLoans collection to store the Loan objects by using the following code segment:
Collection<Loan> largeCustomerLoans = new Collection<Loan>();
All loans with an Amount value greater than or equal to 4000 must be tracked.
You need to populate the largeCustomerLoans collection with Loan objects.
Which code segment should you use?
A. Option A
B. Option B
C. Option C
D. Option D
Answer: D
Explanation: Must add to the largeCustomerLoans collection, not the customerLoanCollection.
We iterate through each customer in customerCollection and check each loan belonging to this customer.
Q18. - (Topic 2)
You are developing an application that includes the following code segment. (Line numbers are included for reference only.)
You need to ensure that the DoWork(Widget widget) method runs.
With which code segment should you replace line 24?
A. DoWork((Widget)o);
B. DoWork(new Widget(o));
C. DoWork(o is Widget);
D. DoWork((ItemBase)o);
Answer: A
Q19. HOTSPOT - (Topic 2)
You have an existing order processing system that accepts .xml files,
The following code shows an example of a properly formatted order in XML:
You create the following class that will be serialized:
For each of the following properties, select Yes if the property is serialized according to the defined schema. Otherwise, select No.
Answer:
Q20. - (Topic 2)
You are developing an application that uses multiple asynchronous tasks to optimize performance.
You need to retrieve the result of an asynchronous task.
Which code segment should you use?
A. Option A B. Option B
C. Option C
D. Option D
Answer: C