MCSD Programming in C# v1.0 (70-483)

Page:    1 / 19   
Total 280 questions

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.)


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

You are developing an application by using C#.
The application includes an object that performs a long running process.
You need to ensure that the garbage collector does not release the object's resources until the process completes.
Which garbage collector method should you use?

  • A. WaitForFullGCComplete()
  • B. SuppressFinalize()
  • C. WaitForFullGCApproach()
  • D. WaitForPendingFinalizers()


Answer : B

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?


  • A. Option A
  • B. Option B
  • C. Option C
  • D. Option D


Answer : D

Explanation:
Once an exception is thrown, part of the information it carries is the stack trace. The stack trace is a list of the method call hierarchy that starts with the method that throws the exception and ends with the method that catches the exception. If an exception is re-thrown by specifying the exception in the throw statement, the stack trace is restarted at the current method and the list of method calls between the original method that threw the exception and the current method is lost. To keep the original stack trace information with the exception, use the throw statement without specifying the exception.
References:
https://docs.microsoft.com/en-us/previous-versions/visualstudio/visual-studio-2012/ms182363(v=vs.110)

DRAG DROP -
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.)
Select and Place:




Answer :

You are developing an application that includes a class named BookTracker for tracking library books. The application includes the following code segment. (Line numbers are included for reference only.)


You need to add a book to the BookTracker instance.
What should you do?

A.

B.

C.

D.



Answer : A

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?

  • A. Create a task within the operation, and set the Task.StartOnError property to true.
  • B. Create a TaskFactory object and call the ContinueWhenAll() method of the object.
  • C. Create a task by calling the Task.ContinueWith() method.
  • D. Use the TaskScheduler class to create a task and call the TryExecuteTask() method on the class.
  • E. Create a TaskCompletionSource<T> object and call the TrySetException() method of the object.
  • F. Examine the Task.Status property immediately after the call to the Task.Run() method.
  • G. Create a task inside the existing Task.Run() method by using the AttachedToParent option.


Answer : C

Explanation:
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.
References:
http://msdn.microsoft.com/en-us/library/dd270696.aspx

You have the following code. (Line numbers are included for reference only.)


What is the output of line 04?

  • A. Error
  • B. 0
  • C. null
  • D. NaN


Answer : B

References:
https://www.dotnetperls.com/divide

DRAG DROP -
You have the following code:

parameter into the CompanyInfo class.
How should you complete the code? To answer, drag the appropriate code elements to the correct targets. 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.
NOTE: Each correct selection is worth one point.
Select and Place:



Answer :

References:
https://docs.microsoft.com/en-us/dotnet/framework/wcf/feature-details/how-to-serialize-and-deserialize-json-data

HOTSPOT -
You are developing a method named Method1 for a class named Class1. and returns to a decimal value.
You need to ensure that calls to Method1 support being executed on separate threads.
How should you complete the method signature? To answer, select the appropriate options in the answer area.
NOTE: Each correct selection is worth one point.
Hot Area:




Answer :

Reference:
https://docs.microsoft.com/en-us/dotnet/csharp/async

You are creating an application that manages information about your company's products. The application includes a class named Product and a method named
.

Save -
The Save() method must be strongly typed. It must allow only types inherited from the Product class that use a constructor that accepts no parameters.
You need to implement the Save() method.
Which code segment should you use?


A.

B.

C.

D.



Answer : D

You are creating a class named Employee. The class exposes a string property named EmployeeType. The following code segment defines the Employee class. (Line numbers are included for reference only.)


The EmployeeType property value must meet the following requirements:
The value must be accessed only by code within the Employee class or within a class derived from the Employee class.
The value must be modified only by code within the Employee class.
You need to ensure that the implementation of the EmployeeType property meets the requirements.
Which two actions should you perform? (Each correct answer represents part of the complete solution. Choose two.)
NOTE: Each correct selection is worth one point.

  • A. Replace line 03 with the following code segment: public string EmployeeType
  • B. Replace line 06 with the following code segment: protected set;
  • C. Replace line 05 with the following code segment: private get;
  • D. Replace line 05 with the following code segment: protected get;
  • E. Replace line 03 with the following code segment: protected string EmployeeType
  • F. Replace line 06 with the following code segment: private set;


Answer : EF

You are developing an application by using C#.
The application includes an object that performs a long running process.
You need to ensure that the garbage collector does not release the object's resources until the process completes.
Which garbage collector method should you use?

  • A. RemoveMemoryPressure()
  • B. ReRegisterForFinalize()
  • C. WaitForFullGCComplete()
  • D. KeepAlive()
  • E. Collect()


Answer : D

You have the following C# code.
StringBuilder sb = new StringBuilder(reallyLongString);
The reallyLongString variable is a string in which a very long string is stored.
You need to identify whether a string stored in an object named StringToFind is within the StringBuilder sb object.
Which code should you use?

  • A. sb.Equals(stringToFind);
  • B. sb.ToString().IndexOf(stringToFind);
  • C. sb.ToString().CompareTo(stringToFind);
  • D. sb.ToString().Substring(stringToFind.Length);


Answer : A

References:
https://docs.microsoft.com/en-us/dotnet/api/system.text.stringbuilder.equals?view=netframework-
4.7.2#System_Text_StringBuilder_Equals_System_Text_StringBuilder_

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.)
Select and Place:




Answer :

Explanation:
Note:
Example:
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);

You are developing an application. The application calls a method that returns an array of integers named customerIds.
You define an integer variable named customerIdToRemove and assign a value to it. You declare an array named filteredCustomerIds.
You have the following requirements.
-> Remove duplicate integers from the customerIds array.
-> Sort the array in order from the highest value to the lowest value.
-> Remove the integer value stored in the customerIdToRemove variable from the customerIds array.
You need to create a LINQ query to meet the requirements.
Which code segment should you use?


  • A. Option A
  • B. Option B
  • C. Option C
  • D. Option D


Answer : C

Page:    1 / 19   
Total 280 questions