70-483 Exam - Programming in C#

certleader.com

Q1. DRAG DROP - (Topic 2) 

You are developing an application that will write string values to a file. The application includes the following code segment. (Line numbers are included for reference only.) 

01 protected void ProcessFile(string fileName, string value) 02 { 

04 } 

You need to ensure that the ProcessFile() method will write string values to a file. 

Which four code segments should you insert in sequence at line 03? (To answer, move the appropriate code segments from the list of code segments to the answer area and arrange them in the correct order.) 

Answer:  

Q2. - (Topic 2) 

You are testing an application. The application includes methods named CalculateInterest and LogLine. The CalculateInterest() method calculates loan interest. The LogLine() method sends diagnostic messages to a console window. 

The following code implements the methods. (Line numbers are included for reference only.) 

You have the following requirements: 

. The CalculateInterest() method must run for all build configurations. . The LogLine() method must run only for debug builds. 

You need to ensure that the methods run correctly. 

What are two possible ways to achieve this goal? (Each correct answer presents a complete solution. Choose two.) 

A. Insert the following code segment at line 01: 

#region DEBUG 

Insert the following code segment at line 10: 

#endregion 

B. Insert the following code segment at line 01: 

[Conditional("DEBUG")] 

C. Insert the following code segment at line 05: 

#region DEBUG 

Insert the following code segment at line 07: 

#endregion 

D. Insert the following code segment at line 10: 

[Conditional("DEBUG")] 

E. Insert the following code segment at line 01: 

#if DEBUG 

Insert the following code segment at line 10: 

#endif 

F. Insert the following code segment at line 10: 

[Conditional("RELEASE")] 

G. Insert the following code segment at line 05: 

#if DEBUG 

Insert the following code segment at line 07: 

#endif 

Answer: D,G 

Reference: http://stackoverflow.com/questions/2104099/c-sharp-if-then-directives-for-debug-vs-release 

Q3. - (Topic 2) 

You are developing an application in C#. 

The application uses exception handling on a method that is used to execute mathematical calculations by using integer numbers. 

You write the following catch blocks for the method (line numbers are included for reference only): 

You need to add the following code to the method: 

At which line should you insert the code? 

A. 01 

B. 03 

C. 05 

D. 07 

Answer:

Q4. - (Topic 2) 

You are developing an application that includes methods named EvaluateLoan, ProcessLoan, and FundLoan. The application defines build configurations named TRIAL, BASIC, and ADVANCED. 

You have the following requirements: 

The TRIAL build configuration must run only the EvaluateLoan() method. 

The BASIC build configuration must run all three methods. 

The ADVANCED build configuration must run only the EvaluateLoan() and 

ProcessLoan() methods. 

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:

Q5. DRAG DROP - (Topic 1) 

You are developing an application by using C#. The application will output the text string "First Line" followed by the text string "Second Line". 

You need to ensure that an empty line separates the text strings. 

Which four code segments should you use in sequence? (To answer, move the appropriate code segments to the answer area and arrange them in the correct order.) 

Answer:  

Q6. - (Topic 2) 

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? 

A. DbDataReader 

B. DataContext 

C. unTyped DataSet 

D. DbDataAdapter 

Answer:

Explanation: DbDataReader Class 

Reads a forward-only stream of rows from a data source. 

Q7. - (Topic 2) 

You are developing an application by using C#. The application includes a method named SendMessage. The SendMessage() method requires a string input. 

You need to replace "Hello" with "Goodbye" in the parameter that is passed to the SendMessage() 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: B,C 

Explanation: * The first parameter should be Hello. 

* String.Replace Method (String, String) 

Returns a new string in which all occurrences of a specified string in the current instance are replaced with another specified string. 

This method does not modify the value of the current instance. Instead, it returns a new string in which all occurrences of oldValue are replaced by newValue. 

Q8. - (Topic 2) 

You are developing an application that includes the following code segment: 

You need to implement both Start() methods in a derived class named UseStart that uses the Start() method of each interface. 

Which two code segments should you use? (Each correct answer presents part of the solution. Choose two.) 

A. Option A 

B. Option B 

C. Option C 

D. Option D 

E. Option E 

F. Option F 

Answer: B,E 

Explanation: B: 

* Implementing Multiple Interfaces 

A class can implement multiple interfaces using the following syntax: 

C# 

public class CDAndDVDComboPlayer : ICDPlayer, IDVDPlayer 

If a class implements more than one interface where there is ambiguity in the names of members, it is resolved using the full qualifier for the property or method name. In other words, the derived class can resolve the conflict by using the fully qualified name for the method to indicate to which interface it belongs 

* In C#, both inheritance and interface implementation are defined by the : operator, equivalent to extends and implements in Java. The base class should always be leftmost in the class declaration. 

Q9. DRAG DROP - (Topic 2) 

You are adding a function to a membership tracking application- The function uses an integer named memberCode as an input parameter and returns the membership type as a string. 

The function must meet the following requirements: 

Return "Non-Member" if the memberCode is 0. 

Return "Member" if the memberCode is 1. 

Return "Invalid" if the memberCode is any value other than 0 or 1. 

You need to implement the function to meet the requirements. 

How should you complete the relevant code? (To answer, drag the appropriate statements to the correct locations in the answer area. Each statement 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 implementing a method named ProcessReports that performs a long-running task. The ProcessReports() method has the following method signature: 

public void ProcessReports(List<decimal> values,CancellationTokenSource cts, CancellationToken ct) 

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 ProcessReports() method performs the required actions. 

Which code segment should you use in the method body? 

A. if (ct.IsCancellationRequested) return; 

B. ct.ThrowIfCancellationRequested() ; 

C. cts.Cancel(); 

D. throw new AggregateException(); 

Answer: