MCSD Programming in C# v1.0

Page:    1 / 19   
Exam contains 284 questions

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. HMACSHA256
  • B. RNGCryptoServiceProvider
  • C. DES
  • D. Aes
  • E. RSA
  • F. Rfc2898DeriveBytes


Answer : A

Explanation:
Explanation:
The .NET Framework provides the following classes that implement hashing algorithms:
-> HMACSHA1.
-> MACTripleDES.
-> MD5CryptoServiceProvider.
-> RIPEMD160.
-> SHA1Managed.
-> SHA256Managed.
-> SHA384Managed.
-> SHA512Managed.
HMAC variants of all of the Secure Hash Algorithm (SHA), Message Digest 5 (MD5), and RIPEMD-160 algorithms.
CryptoServiceProvider implementations (managed code wrappers) of all the SHA algorithms.
Cryptography Next Generation (CNG) implementations of all the MD5 and SHA algorithms.
References:
http://msdn.microsoft.com/en-us/library/92f9ye3s.aspx#hash_values

DRAG DROP -
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.
You have the following requirements:
-> The CalculateInterest() method must run for all build configurations.
-> The LogLine() method must be called only for debug builds.
You need to ensure that the methods run correctly.
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.)
Select and Place:




Answer :

You are developing an assembly that will be used by multiple applications.
You need to install the assembly in the Global Assembly Cache (GAC).
Which two actions can you perform to achieve this goal? Each correct answer presents a complete solution.
NOTE: Each correct selection is worth one point.

  • A. Use the Assembly Registration tool (regasm.exe) to register the assembly and to copy the assembly to the GAC.
  • B. Use the Strong Name tool (sn.exe) to copy the assembly into the GAC.
  • C. Use Microsoft Register Server (regsvr32.exe) to add the assembly to the GAC.
  • D. Use the Global Assembly Cache tool (gacutil.exe) to add the assembly to the GAC.
  • E. Use Windows Installer 2.0 to add the assembly to the GAC.


Answer : DE

Explanation:
There are two ways to deploy an assembly into the global assembly cache:
Use an installer designed to work with the global assembly cache. This is the preferred option for installing assemblies into the global assembly cache.
Use a developer tool called the Global Assembly Cache tool (Gacutil.exe), provided by the Windows
Software Development Kit (SDK).
Note:
In deployment scenarios, use Windows Installer 2.0 to install assemblies into the global assembly cache. Use the Global Assembly Cache tool only in development scenarios, because it does not provide assembly reference counting and other features provided when using the Windows Installer.
References:
http://msdn.microsoft.com/en-us/library/yf1d93sz%28v=vs.110%29.aspx

You are debugging an application that calculates loan interest. The application includes the following code. (Line numbers are included for reference only.)


You need to ensure that the debugger breaks execution within the CalculateInterest() method when the loanAmount variable is less than or equal to zero in all builds of the application.
What should you do?

  • A. Insert the following code segment at line 03:Trace.Assert(loanAmount > 0);
  • B. Insert the following code segment at line 03:Debug.Assert(loanAmount > 0);
  • C. Insert the following code segment at line 05:Debug.Write(loanAmount > 0);
  • D. Insert the following code segment at line 05:Trace.Write(loanAmount > 0);


Answer : A

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

You are developing an application that accepts the input of dates from the user.
Users enter the date in their local format. The date entered by the user is stored in a string variable named inputDate. The valid date value must be placed in a
DateTime variable named validatedDate.
You need to validate the entered date and convert it to Coordinated Universal Time (UTC). The code must not cause an exception to be thrown.
Which code segment should you use?


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


Answer : A

Explanation:
AdjustToUniversal parses s and, if necessary, converts it to UTC.
Note: The DateTime.TryParse method converts the specified string representation of a date and time to its DateTime equivalent using the specified culture- specific format information and formatting style, and returns a value that indicates whether the conversion succeeded.

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:
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 by using C#. You provide a public key to the development team during development.
You need to specify that the assembly is not fully signed when it is built.
Which two assembly attributes should you include in the source code? Each correct answer presents part of the solution.
NOTE: Each correct selection is worth one point.

  • A. AssemblyKeyNameAttribute
  • B. ObfuscateAssemblyAttribute
  • C. AssemblyDelaySignAttribute
  • D. AssemblyKeyFileAttribute
  • E. AssemblyFlagsAttribute
  • F. AssemblyConfigurationAttribute


Answer : CD

References:
http://msdn.microsoft.com/en-us/library/t07a3dye(v=vs.110).aspx

DRAG DROP -
You are developing an application that includes a class named Warehouse. The Warehouse class includes a static property named Inventory- The Warehouse class is defined by the following code segment. (Line numbers are included for reference only.)


You have the following requirements:
-> Initialize the _inventory field to an Inventory instance.
-> Initialize the _inventory field only once.
-> Ensure that the application code acquires a lock only when the _inventory object must be instantiated.
You need to meet the requirements.
Which three code segments should you insert in sequence at line 09? (To answer, move the appropriate code segments from the list of code segments to the answer area and arrange them in the correct order.)
Select and Place:



Answer :

Explanation:
After taking a lock you must check once again the _inventory field to be sure that other threads didn't instantiated it in the meantime.

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?


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


Answer : A

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 user to the BookTracker instance. What should you do?

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


Answer : B

DRAG DROP -
You are implementing a method that creates an instance of a class named User and adds the user to the users list. 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.
You have the following code:


Which code segments should you include in Target 1 and Target 2 to complete the code? To answer, drag the appropriate code segments to the correct targets.
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.
NOTE: Each correct selection is worth one point.
Select and Place:



Answer :

You are creating a console application by using C#.
You need to access the assembly found in the file named car.dll.
Which code segment should you use?

  • A. Assembly.Load();
  • B. Assembly.GetExecutingAssembly();
  • C. This.GetType();
  • D. Assembly.LoadFile("car.dll");


Answer : D

Explanation:
Assembly.LoadFile - Loads the contents of an assembly file on the specified path.
References:
http://msdn.microsoft.com/en-us/library/b61s44e8.aspx

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. WaitForFullGCApproach()
  • C. KeepAlive()
  • D. WaitForPendingFinalizers()


Answer : C

Explanation:
The GC.KeepAlive method references the specified object, which makes it ineligible for garbage collection from the start of the current routine to the point where this method is called.
The purpose of the KeepAlive method is to ensure the existence of a reference to an object that is at risk of being prematurely reclaimed by the garbage collector.
The KeepAlive method performs no operation and produces no side effects other than extending the lifetime of the object passed in as a parameter.

An application includes a class named Person. The Person class includes a method named GetData.
You need to ensure that the GetData() method can be used only by the Person class and not by any class derived from the Person class.
Which access modifier should you use for the GetData() method?

  • A. Public
  • B. Protected internal
  • C. Internal
  • D. Private
  • E. Protected


Answer : D

Explanation:
The GetData() method should be private. It would then only be visible within the Person class.

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




Answer :

Explanation:
Box 1:


First we create the variable.
Box 2:

We create the first text line.
Box 3:

We add a blank line.
The StringBuilder.AppendLine method appends the default line terminator to the end of the current StringBuilder object.
Box 4:

Finally, we add the second line.

Page:    1 / 19   
Exam contains 284 questions

Talk to us!


Have any questions or issues ? Please dont hesitate to contact us

Certlibrary.com is owned by MBS Tech Limited: Room 1905 Nam Wo Hong Building, 148 Wing Lok Street, Sheung Wan, Hong Kong. Company registration number: 2310926
Certlibrary doesn't offer Real Microsoft Exam Questions. Certlibrary Materials do not contain actual questions and answers from Cisco's Certification Exams.
CFA Institute does not endorse, promote or warrant the accuracy or quality of Certlibrary. CFA® and Chartered Financial Analyst® are registered trademarks owned by CFA Institute.
Terms & Conditions | Privacy Policy