最新的Microsoft Programming in C# - 70-483免費考試真題

問題1
You are implementing a method that creates an instance of a class named User. The User class contains a public event named Renamed. The following code segment defines the Renamed event:
Public event EventHandler<RenameEventArgs> Renamed;
You need to create an event handler for the Renamed event by using a lambda expression.
How should you complete the relevant code? (To answer, drag the appropriate code segments to the correct locations in the answer area. Each code segment 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.)
正確答案:
問題2
You are developing an application that uses structured exception handling. The application includes a class named Logger. The Logger class implements a method named Log by using the following code segment:
public static void Log(Exception ex) { }
You have the following requirements:
* Log all exceptions by using the Log() method of the Logger class.
* Rethrow the original exception, including the entire exception stack.
You need to meet the requirements. Which code segment should you use?

正確答案: B
問題3
You have the following code.

For each of the following statements, select Yes if the statement is true. Otherwise, select No.
正確答案:

Explanation:
References:
https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/inheritance
問題4
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 {
03
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.)
正確答案:

Explanation:
Note:
* Example:
1. StreamWriter.Null Field
Provides a StreamWriter with no backing store that can be written to, but not read from.
2. The StreamWriter Constructor (String) initializes a new instance of the StreamWriter class for the specified file by using the default encoding and buffer size.
3. The StreamWriter.Write method writes data to the stream.
4. The StreamWriter.Close method closes the current StreamWriter object and the underlying stream.
Incorrect:
Not StreamWrite.Open();
The StreamWriter Class does not have any method named Open.
問題5
You are developing an application that uses several objects. The application includes the following code segment. (Line numbers are included for reference only.)

You need to evaluate whether an object is null.
Which code segment should you insert at line 03?

正確答案: B
說明:(僅 VCESoft 成員可見)
問題6
You are developing an application that will read data from a text file and display the file contents.
You need to read data from the file, display it, and correctly release the file resources.
Which code segment should you use?

正確答案: D
說明:(僅 VCESoft 成員可見)
問題7
You are creating a class library that will be used in a web application.
You need to ensure that the class library assembly is strongly named.
What should you do?

正確答案: B
說明:(僅 VCESoft 成員可見)
問題8
You are developing an application that will include a method named GetData. The GetData() method will retrieve several lines of data from a web service by using a System.IO.StreamReader object.
You have the following requirements:
* The GetData() method must return a string value that contains the first line of the response from the web service.
* The application must remain responsive while the GetData() method runs.
You need to implement the GetData() method.
How should you complete the relevant code? (To answer, drag the appropriate objects to the correct locations in the answer area. Each object 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.)
正確答案:

Explanation:
Box 1. async Box 2. await Box 3. ReadLineAsync();
Incorrect:
Not Box 3: ReadToEndAsync() is not correct since only the first line of the response is required.
問題9
You have the following code.

You need to complete the method to return the content as a string.
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.
正確答案:
問題10
You are implementing a new method named ProcessData. The ProcessData() method calls a third-party component that performs a long-running operation.
The third-party component uses the IAsyncResult pattern to signal completion of the long-running operation.
You need to ensure that the calling code handles the long-running operation as a System.Threading.Tasks.Task object.
Which two actions should you perform? (Each correct answer presents part of the solution. Choose two.)

正確答案: B,C
說明:(僅 VCESoft 成員可見)
問題11
You are developing an application that generates code. The application includes the following code segment. (Line numbers are included for reference only.)

You need to ensure that code generated by the GenerateCode() method represents a class that can be accessed by all objects in its application domain.
Which two code segments can you insert at line 05 to achieve this goal? (Each correct answer presents a complete solution. Choose two.)

正確答案: C,D
問題12
You are developing an application that will include a method named GetData. The GetData() method will retrieve several lines of data from a web service by using a System.IO.StreamReader object.
You have the following requirements:
* The GetData() method must return a string value that contains the entire response from the web service.
* The application must remain responsive while the GetData() method runs.
You need to implement the GetData() method.
How should you complete the relevant code? (To answer, drag the appropriate objects to the correct locations in the answer area. Each object 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.)
正確答案:

Explanation:
Box 1. async Box 2. await Box 3. ReadLineAsync();
Incorrect:
Not Box 3: ReadToEndAsync() is not correct since only the first line of the response is required.
問題13
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?

正確答案: C
說明:(僅 VCESoft 成員可見)
問題14
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?

正確答案: B
說明:(僅 VCESoft 成員可見)
問題15
You are building a data access layer in an application that contains the following code:

For each of the following statements, select Yes if the statement is true. Otherwise, select No.
正確答案: