Exam 70-483
Exam 70-483
Number: 70-483
Passing Score: 800
Time Limit: 120 min
File Version: 1
70-483
https://www.gratisexam.com/
Sections
1. Volume A
2. Volume B
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
Exam A
QUESTION 1
You are developing an application that includes a class named Order. The application will store a collection of Order objects.
https://www.gratisexam.com/
A. Queue<T>
B. SortedList
C. LinkedList<T>
D. HashTable
E. Array<T>
Correct Answer: A
Section: Volume A
Explanation
Explanation/Reference:
Explanation:
Queues are useful for storing messages in the order they were received for sequential processing. Objects stored in a Queue<T> are inserted at one end and
removed from the other.
References: http://msdn.microsoft.com/en-us/library/7977ey2c.aspx
QUESTION 2
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
You are developing an application. The application calls a method that returns an array of integers named employeeIds. You define an integer variable named
employeeIdToRemove and assign a value to it. You declare an array named filteredEmployeeIds.
A. Option A
B. Option B
C. Option C
D. Option D
Correct Answer: C
Section: Volume A
Explanation
Explanation/Reference:
QUESTION 3
You are developing an application that includes the following code segment. (Line numbers are included for reference only.)
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
The GetAnimals() method must meet the following requirements:
Which two actions should you perform? Each correct answer presents part of the solution.
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
E. Insert the following code segment at line 16:
while(sqlDataReader.GetValues())
Correct Answer: BD
Section: Volume A
Explanation
Explanation/Reference:
Explanation:
SqlConnection.Open - Opens a database connection with the property settings specified by the ConnectionString.
SqlDataReader.Read - Advances the SqlDataReader to the next record.
References:
http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlconnection.open.aspx
http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqldatareader.read.aspx
QUESTION 4
You have an assembly named Assembly1 that is written in C#. Assembly1 has a method named Method1.
You add a new method named Method2 to Assembly1. Method2 is a newer version of Method1 and must be used by applications in the future.
You need to ensure that if a developer builds a project that uses Method1, the developer is notified that Method1 is deprecated.
A. Set an #if DEPRECATED preprocessor directive above Method1. Set a #endif preprocessor directive after Method1.
B. Set a #pragma warning disable preprocessor inside of Method1.
C. Set a #define preprocessor directive above Method1. Set an #if preprocessor directive inside of Method1.
D. Set a #warning preprocessor directive inside of Method1.
Correct Answer: C
Section: Volume A
Explanation
Explanation/Reference:
Explanation:
You use #define to define a symbol. When you use the symbol as the expression that's passed to the #if directive, the expression will evaluate to true.
Example:
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
#define DEBUG
using System;
Reference:
https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/preprocessor-directives/preprocessor-define
QUESTION 5
You are developing an application. The application includes a method named ReadFile that reads data from a file.
Correct Answer: A
Section: Volume A
Explanation
Explanation/Reference:
Explanation:
FileMode.OpenOrCreate - Specifies that the operating system should open a file if it exists; otherwise, a new file should be created. If the file is opened with
FileAccess.Read, FileIOPermissionAccess.Read permission is required. If the file access is FileAccess.Write, FileIOPermissionAccess.Write permission is
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
required. If the file is opened with FileAccess.ReadWrite, both FileIOPermissionAccess.Read and FileIOPermissionAccess.Write permissions are required.
FileShare.ReadWrite - Allows subsequent opening of the file for reading or writing. If this flag is not specified, any request to open the file for reading or writing (by
this process or another process) will fail until the file is closed. However, even if this flag is specified, additional permissions might still be needed to access the file.
References:
http://msdn.microsoft.com/pl-pl/library/system.io.fileshare.aspx
http://msdn.microsoft.com/en-us/library/system.io.filemode.aspx
QUESTION 6
An application receives JSON data in the following format:
The application includes the following code segment. (Line numbers are included for reference only.)
You need to ensure that the ConvertToName() method returns the JSON input string as a Name object.
A. Return ser.ConvertToType<Name>(json);
B. Return ser.DeserializeObject(json);
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
C. Return ser.Deserialize<Name>(json);
D. Return (Name)ser.Serialize(json);
Correct Answer: C
Section: Volume A
Explanation
Explanation/Reference:
Explanation:
JavaScriptSerializer.Deserialize<T> - Converts the specified JSON string to an object of type T.
References: http://msdn.microsoft.com/en-us/library/bb355316.aspx
QUESTION 7
You are developing an application. The application converts a Location object to a string by using a method named WriteObject. The WriteObject() method accepts
two parameters, a Location object and an XmlObjectSerializer object.
The application includes the following code. (Line numbers are included for reference only.)
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
You need to serialize the Location object as a JSON object.
A. New DataContractSerializer(typeof(Location))
B. New XmlSerializer(typeof(Location))
C. New NetDataContractSerializer()
D. New DataContractJsonSerializer(typeof(Location))
Correct Answer: D
Section: Volume A
Explanation
Explanation/Reference:
Explanation:
The DataContractJsonSerializer class serializes objects to the JavaScript Object Notation (JSON) and deserializes JSON data to objects.
Use the DataContractJsonSerializer class to serialize instances of a type into a JSON document and to deserialize a JSON document into an instance of a type.
QUESTION 8
You are developing an application. The application includes classes named Employee and Person and an interface named IPerson.
You need to ensure that the Employee class meets the requirements.
Which two code segments can you use to achieve this goal? (Each correct answer presents a complete solution. Choose two.)
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
A. Option A
B. Option B
C. Option C
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
D. Option D
Correct Answer: BD
Section: Volume A
Explanation
Explanation/Reference:
Explanation:
Sealed - When applied to a class, the sealed modifier prevents other classes from inheriting from it.
References: http://msdn.microsoft.com/en-us/library/88c54tsw(v=vs.110).aspx
QUESTION 9
You are developing an application that will convert data into multiple output formats.
The application includes the following code. (Line numbers are included for reference only.)
You are developing a code segment that will produce tab-delimited output. All output routines implement the following interface:
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
Which code segment should you insert at line 06?
A. Option A
B. Option B
C. Option C
D. Option D
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
Correct Answer: B
Section: Volume A
Explanation
Explanation/Reference:
Explanation:
A String object concatenation operation always creates a new object from the existing string and the new data.
A StringBuilder object maintains a buffer to accommodate the concatenation of new data. New data is appended to the buffer if room is available; otherwise, a new,
larger buffer is allocated, data from the original buffer is copied to the new buffer, and the new data is then appended to the new buffer.
The performance of a concatenation operation for a String or StringBuilder object depends on the frequency of memory allocations. A String concatenation
operation always allocates memory, whereas a StringBuilder concatenation operation allocates memory only if the StringBuilder object buffer is too small to
accommodate the new data. Use the String class if you are concatenating a fixed number of String objects. In that case, the compiler may even combine individual
concatenation operations into a single operation. Use a StringBuilder object if you are concatenating an arbitrary number of strings; for example, if you're using a
loop to concatenate a random number of strings of user input.
References: http://msdn.microsoft.com/en-us/library/system.text.stringbuilder(v=vs.110).aspx
QUESTION 10
You are developing an application by using C#.
You need to ensure that the garbage collector does not release the object's resources until the process completes.
A. ReRegisterForFinalize()
B. SuppressFinalize()
C. Collect()
D. WaitForFullGCApproach()
Correct Answer: B
Section: Volume A
Explanation
Explanation/Reference:
QUESTION 11
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
You are creating a console application by using C#.
A. Assembly.GetAssembly(this);
B. this.GetType();
C. Assembly.Load();
D. Assembly.GetExecutingAssembly();
Correct Answer: D
Section: Volume A
Explanation
Explanation/Reference:
Explanation:
Assembly.GetExecutingAssembly - Gets the assembly that contains the code that is currently executing.
Assembly.GetAssembly - Gets the currently loaded assembly in which the specified class is defined.
References:
http://msdn.microsoft.com/en-us/library/system.reflection.assembly.getassembly.aspx
http://msdn.microsoft.com/en-us/library/system.reflection.assembly.getexecutingassembly(v=vs.110).aspx
QUESTION 12
You are modifying an application that processes leases. The following code defines the Lease class. (Line numbers are included for reference only.)
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
Leases are restricted to a maximum term of 5 years. The application must send a notification message if a lease request exceeds 5 years.
Which two actions should you perform? (Each correct answer presents part of the solution. Choose two.)
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
A. Option A
B. Option B
C. Option C
D. Option D
E. Option E
F. Option F
Correct Answer: AB
Section: Volume A
Explanation
Explanation/Reference:
QUESTION 13
You are developing an application that includes a class named UserTracker. The application includes the following code segment. (Line numbers are included for
reference only.)
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
You need to add a user to the UserTracker instance.
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
A. Option A
B. Option B
C. Option C
D. Option D
Correct Answer: D
Section: Volume A
Explanation
Explanation/Reference:
QUESTION 14
You are adding a public method named UpdateScore to a public class named ScoreCard.
The code region that updates the score 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.
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
A. Option A
B. Option B
C. Option C
D. Option D
Correct Answer: B
Section: Volume A
Explanation
Explanation/Reference:
References: http://blogs.msdn.com/b/bclteam/archive/2004/01/20/60719.aspx
QUESTION 15
You are developing a C# application that has a requirement to validate some string input data by using the Regex class.
The application includes a method named ContainsHyperlink. The ContainsHyperlink() method will verify the presence of a URI and surrounding markup.
The following code segment defines the ContainsHyperlink() method. (Line numbers are included for reference only.)
The expression patterns used for each validation function are constant.
You need to ensure that the expression syntax is evaluated only once when the Regex object is initially instantiated.
A.
B.
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
C.
D.
Correct Answer: D
Section: Volume A
Explanation
Explanation/Reference:
Explanation:
RegexOptions.Compiled - Specifies that the regular expression is compiled to an assembly. This yields faster execution but increases startup time. This value
should not be assigned to the Options property when calling the CompileToAssembly method.
References:
http://msdn.microsoft.com/en-us/library/system.text.regularexpressions.regexoptions.aspx
http://stackoverflow.com/questions/513412/how-does-regexoptions-compiled-work
QUESTION 16
You are developing an application by using C#.
You need to configure the project to avoid changing individual configuration settings every time you deploy the application to testers.
Which two actions should you perform? (Each correct answer presents part of the solution. Choose two.)
A. Update the platform target and conditional compilation symbols for each application configuration.
B. Create two application configurations based on the default Release configuration.
C. Optimize the application through address rebasing in the 64-bit configuration.
D. Create two application configurations based on the default Debug configuration.
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
Correct Answer: BD
Section: Volume A
Explanation
Explanation/Reference:
QUESTION 17
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.
A. HMACSHA256
B. RNGCryptoServiceProvider
C. DES
D. Aes
E. RSA
F. Rfc2898DeriveBytes
Correct Answer: A
Section: Volume A
Explanation
Explanation/Reference:
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.
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
Cryptography Next Generation (CNG) implementations of all the MD5 and SHA algorithms.
References:
http://msdn.microsoft.com/en-us/library/92f9ye3s.aspx#hash_values
QUESTION 18
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.
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.
Correct Answer: DE
Section: Volume A
Explanation
Explanation/Reference:
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
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
QUESTION 19
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
You are developing an application that includes methods named EvaluateLoan, ProcessLoan, and FundLoan. The application defines build configurations named
TRIAL, BASIC, and ADVANCED.
The TRIAL build configuration must run only the EvaluateLoan() method.
The ADVANCED build configuration must run all three methods.
The BASIC build configuration must run only the EvaluateLoan() and ProcessLoan() methods.
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
A. Option A
B. Option B
C. Option C
D. Option D
Correct Answer: B
Section: Volume A
Explanation
Explanation/Reference:
QUESTION 20
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.
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
A. Option A
B. Option B
C. Option C
D. Option D
Correct Answer: A
Section: Volume A
Explanation
Explanation/Reference:
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.
QUESTION 21
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.
A. AssemblyKeyNameAttribute
B. ObfuscateAssemblyAttribute
C. AssemblyDelaySignAttribute
https://www.gratisexam.com/
D. AssemblyKeyFileAttribute
E. AssemblyFlagsAttribute
F. AssemblyConfigurationAttribute
Correct Answer: CD
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
Section: Volume A
Explanation
Explanation/Reference:
Explanation:
To delay-sign an assembly:
1. Get the public key portion of the key pair from the organization that will do the eventual signing. Typically this key is in the form of an .snk file, which can be
created using the Strong Name tool (Sn.exe) provided by the Windows SDK.
2. Annotate the source code for the assembly with two custom attributes from System.Reflection:
AssemblyDelaySignAttribute, which indicates that delay signing is being used by passing true as a parameter to its constructor.
AssemblyKeyFileAttribute, which passes the name of the file containing the public key as a parameter to its constructor.
Reference:
http://msdn.microsoft.com/en-us/library/t07a3dye(v=vs.110).aspx
QUESTION 22
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.
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
A. Option A
B. Option B
C. Option C
D. Option D
Correct Answer: A
Section: Volume A
Explanation
Explanation/Reference:
QUESTION 23
You are creating a console application by using C#.
You need to access the assembly found in the file named car.dll.
A. Assembly.Load();
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
B. Assembly.GetExecutingAssembly();
C. This.GetType();
D. Assembly.LoadFile("car.dll");
Correct Answer: D
Section: Volume A
Explanation
Explanation/Reference:
Explanation:
Assembly.LoadFile - Loads the contents of an assembly file on the specified path.
References: http://msdn.microsoft.com/en-us/library/b61s44e8.aspx
QUESTION 24
You are developing an application by using C#.
You need to ensure that the garbage collector does not release the object's resources until the process completes.
A. WaitForFullGCComplete()
B. WaitForFullGCApproach()
C. KeepAlive()
D. WaitForPendingFinalizers()
Correct Answer: C
Section: Volume A
Explanation
Explanation/Reference:
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.
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
QUESTION 25
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
Correct Answer: D
Section: Volume A
Explanation
Explanation/Reference:
Explanation:
The GetData() method should be private. It would then only be visible within the Person class.
QUESTION 26
You are developing an application. The application includes classes named Mammal and Animal and an interface named IAnimal.
You need to ensure that the Mammal class meets the requirements.
Which two code segments can you use to achieve this goal? (Each correct answer presents a complete solution. Choose two.)
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
A. Option A
B. Option B
C. Option C
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
D. Option D
Correct Answer: AC
Section: Volume A
Explanation
Explanation/Reference:
Explanation:
When applied to a class, the sealed modifier prevents other classes from inheriting from it.
References: http://msdn.microsoft.com/en-us/library/88c54tsw(v=vs.110).aspx
QUESTION 27
An application receives JSON data in the following format:
The application includes the following code segment. (Line numbers are included for reference only.)
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
You need to ensure that the ConvertToName() method returns the JSON input string as a Name object.
Correct Answer: C
Section: Volume A
Explanation
Explanation/Reference:
QUESTION 28
You are developing an application that includes the following code segment. (Line numbers are included for reference only.)
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
The GetCustomers() method must meet the following requirements:
Connect to a Microsoft SQL Server database.
Populate Customer objects with data from the database.
Return an IEnumerable<Customer> collection that contains the populated Customer objects.
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
E. Insert the following code segment at line 17:
while (sqlDataReader.NextResult())
Correct Answer: BD
Section: Volume A
Explanation
Explanation/Reference:
Explanation:
SqlConnection.Open - Opens a database connection with the property settings specified by the ConnectionString.
SqlDataReader.Read - Advances the SqlDataReader to the next record.
References:
http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlconnection.open.aspx
http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqldatareader.read.aspx
QUESTION 29
An application will upload data by using HTML form-based encoding. The application uses a method named SendMessage.
The SendMessage() method includes the following code. (Line numbers are included for reference only.)
You need to send the values intA and intB as form-encoded values named a and b, respectively.
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
A. Option A
B. Option B
C. Option C
D. Option D
Correct Answer: D
Section: Volume A
Explanation
Explanation/Reference:
Explanation:
WebClient.UploadValuesTaskAsync - Uploads the specified name/value collection to the resource identified by the specified URI as an asynchronous operation
using a task object. These methods do not block the calling thread.
References: http://msdn.microsoft.com/en-us/library/system.net.webclient.uploadvaluestaskasync.aspx
QUESTION 30
You are developing an application. The application converts a Location object to a string by using a method named WriteObject.
The WriteObject() method accepts two parameters, a Location object and an XmlObjectSerializer object.
The application includes the following code. (Line numbers are included for reference only.)
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
You need to serialize the Location object as XML.
A. new XmlSerializer(typeof(Location))
B. new NetDataContractSerializer()
C. new DataContractJsonSerializer(typeof (Location))
D. new DataContractSerializer(typeof(Location))
Correct Answer: D
Section: Volume A
Explanation
Explanation/Reference:
Explanation:
The code is using [DataContract] attribute here so need to used DataContractSerializer class.
QUESTION 31
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
You are developing an application that includes a class named Order. The application will store a collection of Order objects.
A. LinkedList
B. Queue
C. Array
D. HashTable
E. SortedList
Correct Answer: E
Section: Volume A
Explanation
Explanation/Reference:
Explanation:
SortedList<TKey, TValue> - Represents a collection of key/value pairs that are sorted by key based on the associated IComparer<T> implementation.
References: http://msdn.microsoft.com/en-us/library/ms132319.aspx
QUESTION 32
You are developing an application that includes the following code segment. (Line numbers are included for reference only.)
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
You need to ensure that the application accepts only integer input and prompts the user each time non-integer input is entered.
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
Which code segment should you add at line 19?
A. Option A
B. Option B
C. Option C
D. Option D
Correct Answer: A
Section: Volume A
Explanation
Explanation/Reference:
Explanation:
Int32.TryParse - Converts the string representation of a number to its 32-bit signed integer equivalent. A return value indicates whether the conversion succeeded.
Incorrect Answers:
B, C: These will throwan exception when user enters non-integer value.
D: This is exactly the opposite what we want to achieve.
References: http://msdn.microsoft.com/en-us/library/f02979c7.aspx
QUESTION 33
You are debugging an application that calculates loan interest. The application includes the following code. (Line numbers are included for reference only.)
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
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.
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);
Correct Answer: C
Section: Volume A
Explanation
Explanation/Reference:
Explanation:
By default, the Debug.Assert method works only in debug builds.
Incorrect:
Not D: Use the Trace.Assert method if you want to do assertions in release builds.
Reference:
https://docs.microsoft.com/en-us/dotnet/api/system.diagnostics.debug.assert
QUESTION 34
You are developing an application that will process orders. The debug and release versions of the application will display different logo images.
You need to ensure that the correct image path is set based on the build configuration.
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
Which code segment should you use?
A.
B.
C.
D.
Correct Answer: C
Section: Volume A
Explanation
Explanation/Reference:
Explanation:
There is no such constraint (unless you define one explicitly) RELEASE.
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
References: http://stackoverflow.com/questions/507704/will-if-release-work-like-if-debug-does-in-c
QUESTION 35
You are developing an application by using C#.
You need to ensure that the garbage collector does not release the object's resources until the process completes.
A. WaitForFullGCComplete()
B. SuppressFinalize()
C. collect()
D. RemoveMemoryPressure()
Correct Answer: B
Section: Volume A
Explanation
Explanation/Reference:
QUESTION 36
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.
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
Which code segment should you insert at line 04?
A. Option A
B. Option B
C. Option C
D. Option D
Correct Answer: D
Section: Volume A
Explanation
Explanation/Reference:
QUESTION 37
You are developing an application by using C#.
You need to ensure that the garbage collector does not release the object's resources until the process completes.
A. WaitForFullGCComplete()
B. SuppressFinalize()
C. WaitForFullGCApproach()
D. WaitForPendingFinalizers()
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
Correct Answer: B
Section: Volume A
Explanation
Explanation/Reference:
QUESTION 38
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:
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?
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
A. Option A
B. Option B
C. Option C
D. Option D
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
Correct Answer: D
Section: Volume A
Explanation
Explanation/Reference:
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)
QUESTION 39
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.)
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
You need to add a book to the BookTracker instance.
A.
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
B.
C.
D.
Correct Answer: A
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
Section: Volume A
Explanation
Explanation/Reference:
QUESTION 40
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.
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.
Correct Answer: C
Section: Volume A
Explanation
Explanation/Reference:
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.
Reference: http://msdn.microsoft.com/en-us/library/dd270696.aspx
QUESTION 41
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.
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
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.
A.
B.
C.
D.
Correct Answer: D
Section: Volume A
Explanation
Explanation/Reference:
QUESTION 42
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.)
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
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.)
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
A. Option A
B. Option B
C. Option C
D. Option D
E. Option E
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
F. Option F
Correct Answer: EF
Section: Volume A
Explanation
Explanation/Reference:
QUESTION 43
You are developing an application by using C#.
You need to ensure that the garbage collector does not release the object's resources until the process completes.
A. RemoveMemoryPressure()
B. ReRegisterForFinalize()
C. WaitForFullGCComplete()
D. KeepAlive()
E. Collect()
Correct Answer: D
Section: Volume A
Explanation
Explanation/Reference:
QUESTION 44
You have the following C# code.
You need to identify whether a string stored in an object named StringToFind is within the StringBuilder sb object.
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
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);
Correct Answer: A
Section: Volume A
Explanation
Explanation/Reference:
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_
QUESTION 45
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.
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
A. Option A
B. Option B
C. Option C
D. Option D
Correct Answer: C
Section: Volume A
Explanation
Explanation/Reference:
QUESTION 46
You are developing a C# application that includes a class named Product. The following code segment defines the Product class:
You implement System.ComponentModel.DataAnnotations.IValidatableObject interface to provide a way to validate the Product object.
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
The Product object has the following requirements:
The Id property must have a value greater than zero.
The Name property must have a value other than empty or null.
You need to validate the Product object. Which code segment should you use?
A.
B.
C.
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
D.
Correct Answer: B
Section: Volume A
Explanation
Explanation/Reference:
QUESTION 47
You are creating a class named Game.
A. protected field
B. public static field
C. public static property
D. public property
Correct Answer: D
Section: Volume A
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
Explanation
Explanation/Reference:
QUESTION 48
You are developing an application.
The application contains the following code segment. (Line numbers are included for reference only.):
When you run the code, you receive the following error message: "Cannot implicitly convert type 'object'' to 'int'. An explicit conversion exists (are you missing a
cast?)."
A.
B.
C.
D.
Correct Answer: C
Section: Volume A
Explanation
Explanation/Reference:
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
QUESTION 49
You are developing code for a class named Account. The Account class includes the following method:
You need to ensure that overflow exceptions are thrown when there is an error.
A. checked
B. try
C. using
D. unchecked
Correct Answer: A
Section: Volume A
Explanation
Explanation/Reference:
Explanation:
The checked keyword is used to explicitly enable overflow checking for integral-type arithmetic operations and conversions.
References:
https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/checked
https://docs.microsoft.com/en-us/dotnet/api/system.overflowexception?view=netframework-4.7.2
QUESTION 50
You are developing an application that uses a .config file.
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
The relevant portion of the .config file is shown as follows:
You need to ensure that diagnostic data for the application writes to the event tog by using the configuration specified in the .config file.
A. Option A
B. Option B
C. Option C
D. Option D
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
Correct Answer: D
Section: Volume A
Explanation
Explanation/Reference:
Explanation:
Public static void Main(string[] args) {
Create a trace listener for the event log.
EventLogTraceListener myTraceListener = new EventLogTraceListener("myEventLogSource");
Add the event log trace listener to the collection.
Trace.Listeners.Add(myTraceListener);
// Write output to the event log.
Trace.WriteLine("Test output");
}
References: http://msdn.microsoft.com/en-us/library/vstudio/system.diagnostics.eventlogtracelistener
QUESTION 51
You have the following code (line numbers are included for reference only):
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
You need to identify the missing line of code at line 15. Which line of code should you identify?
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
A. Option A
B. Option B
C. Option C
D. Option D
Correct Answer: B
Section: Volume A
Explanation
Explanation/Reference:
QUESTION 52
You have an assembly named Assembly1 that is written in C#. Assembly1 has a method named Method1.
You add a new method named Method2 to Assembly1. Method2 is a newer version of Method1 and must be used by applications in the future.
You need to ensure that if a developer builds a project that uses Method1, the developer is notified that Method1 is deprecated.
A. Set an #if DEPRECATED preprocessor directive above Method1. Set a #endif preprocessor directive after Method1.
B. Set a #pragma warning disable preprocessor inside of Method1.
C. Mark Method1 with an ObsoleteAttribute attribute.
D. Mark Method1 with a Conditional attribute that is set to WARNING.
E. Set a #warning preprocessor directive inside of Method1.
Correct Answer: C
Section: Volume A
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
Explanation
Explanation/Reference:
Explanation:
ObsoleteAttribute is applicable to all program elements except assemblies, modules, parameters, and return values. Marking an element as obsolete informs users
that the element will be removed in future versions of the product.
Reference:
https://docs.microsoft.com/en-us/dotnet/api/system.obsoleteattribute?view=netframework-4.7.2
QUESTION 53
You are creating a console application named App1.
App1 retrieves data from the Internet by using JavaScript Object Notation (JSON).
You are developing the following code segment (line numbers are included for reference only):
You need to ensure that the code validates the JSON string.
Correct Answer: D
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
Section: Volume A
Explanation
Explanation/Reference:
Explanation:
The JavaScriptSerializer Class Provides serialization and deserialization functionality for AJAX-enabled applications.
The JavaScriptSerializer class is used internally by the asynchronous communication layer to serialize and deserialize the data that is passed between the browser
and the Web server. You cannot access that instance of the serializer. However, this class exposes a public API. Therefore, you can use the class when you want
to work with JavaScript Object Notation (JSON) in managed code.
QUESTION 54
You are developing an application that uses several objects. The application includes the following code segment. (Line numbers are included for reference only.)
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
A. Option A
B. Option B
C. Option C
D. Option D
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
Correct Answer: D
Section: Volume A
Explanation
Explanation/Reference:
Explanation:
Use the == operator to compare values and in this case also use the null literal.
QUESTION 55
You are developing an application.
The application contains the following code segment (line numbers are included for reference only):
When you run the code, you receive the following error message: "Cannot implicitly convert type 'object'' to 'int'. An explicit conversion exists (are you missing a
cast?)."
A. var2 = ((List<int>)array1)[0];
B. var2 = (int)array1[0];
C. var2 = ((int[])array1)[0];
D. var2 = array1[0] as int;
Correct Answer: B
Section: Volume B
Explanation
Explanation/Reference:
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
QUESTION 56
You need to write a method that retrieves data from a Microsoft Access 2013 database.
It must be read-only.
You must be able to use the data before the entire data set is retrieved.
You must minimize the amount of system overhead and the amount of memory usage.
A. SqlDataAdapter
B. DataContext
C. DbDataAdapter
D. OleDbDataReader
Correct Answer: D
Section: Volume B
Explanation
Explanation/Reference:
Explanation:
OleDbDataReader Class
Provides a way of reading a forward-only stream of data rows from a data source.
Example:
OleDbConnection cn = new OleDbConnection();
OleDbCommand cmd = new OleDbCommand();
DataTable schemaTable;
OleDbDataReader myReader;
QUESTION 57
You have the following code:
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
You need to retrieve all of the numbers from the items variable that are greater than 80.
A. Option A
B. Option B
C. Option C
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
D. Option D
Correct Answer: A
Section: Volume B
Explanation
Explanation/Reference:
QUESTION 58
You are implementing a method named ProcessReports that performs a long-running task. The ProcessReports() method has the following method
signature:
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.
A. if (ct.IsCancellationRequested)return;
B. ct.ThrowIfCancellationRequested() ;
C. cts.Cancel();
D. throw new AggregateException();
Correct Answer: B
Section: Volume B
Explanation
Explanation/Reference:
QUESTION 59
You are developing an application that will be deployed to multiple computers. You set the assembly name.
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
Which two assembly identity attributes should you include in the source code? (Each correct answer presents part of the solution. Choose two.)
A. AssemblyTitleAttribute
B. AssemblyCultureAttribute
C. AssemblyVersionAttribute
D. AssemblyKeyNameAttribute
E. AssemblyFileVersion
F. AssemblyProductAttribute
G. AssemblyDelaySignAttribute
H. AssemblyCompanyAttribute
Correct Answer: BC
Section: Volume B
Explanation
Explanation/Reference:
Explanation:
The AssemblyName object contains information about an assembly, which you can use to bind to that assembly. An assembly's identity consists of the following:
Simple name
Version number
Cryptographic key pair
Supported culture
B: AssemblyCultureAttribute
Specifies which culture the assembly supports.
The attribute is used by compilers to distinguish between a main assembly and a satellite assembly. A main assembly contains code and the neutral culture's
resources. A satellite assembly contains only resources for a particular culture, as in [assembly:AssemblyCultureAttribute("de")]
C: AssemblyVersionAttribute
Specifies the version of the assembly being attributed.
The assembly version number is part of an assembly's identity and plays a key part in binding to the assembly and in version policy.
Reference:
https://docs.microsoft.com/en-us/dotnet/framework/app-domains/assembly-names
QUESTION 60
You are developing an application.
You need to declare a delegate for a method that accepts an integer as a parameter, and then returns an integer.
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
Which type of delegate should you use?
A. Action<int>
B. Action<int,int>
C. Func<int,int>
D. Func<int>
Correct Answer: C
Section: Volume B
Explanation
Explanation/Reference:
QUESTION 61
You are writing the following method (line numbers are included for reference only):
Correct Answer: A
Section: Volume B
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
Explanation
Explanation/Reference:
QUESTION 62
You are developing an application that includes the following code segment. (Line numbers are included for reference only.)
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
You need to ensure that the DoWork(Widget widget) method runs.
A. Option A
B. Option B
C. Option C
D. Option D
Correct Answer: A
Section: Volume B
Explanation
Explanation/Reference:
QUESTION 63
An application uses X509 certificates for data encryption and decryption. The application stores certificates in the Personal certificates collection of the Current User
store. On each computer, each certificate subject is unique.
The application includes a method named LoadCertificate. The LoadCertificate() method includes the following code. (Line numbers are included for
reference only.)
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
The LoadCertificate() method must load only certificates for which the subject exactly matches the searchValue parameter value.
You need to ensure that the LoadCertificate() method loads the correct certificates.
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
https://www.gratisexam.com/
A. Option A
B. Option B
C. Option C
D. Option D
Correct Answer: D
Section: Volume B
Explanation
Explanation/Reference:
QUESTION 64
You are developing a class named Scorecard. The following code implements the Scorecard class. (Line numbers are included for reference only.)
You create the following unit test method to test the Scorecard class implementation:
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
You need to ensure that the unit test will pass.
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
A. Option A
B. Option B
C. Option C
D. Option D
Correct Answer: A
Section: Volume B
Explanation
Explanation/Reference:
QUESTION 65
You are developing an application that will parse a large amount of text.
You need to parse the text into separate lines and minimize memory use while processing data.
A. DataContractSerializer
B. StringBuilder
C. StringReader
D. JsonSerializer
Correct Answer: C
Section: Volume B
Explanation
Explanation/Reference:
QUESTION 66
You are developing code for an application that retrieves information about Microsoft .NET Framework assemblies.
The following code segment is part of the application (line numbers are included for reference only):
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
You need to insert code at line 04. The code must load the assembly. Once the assembly is loaded, the code must be able to read the assembly metadata, but the
code must be denied access from executing code from the assembly.
A. Assembly.ReflectionOnlyLoadFrom(bytes);
B. Assembly.ReflectionOniyLoad(bytes);
C. Assembly.Load(bytes);
D. Assembly.LoadFrom(bytes);
Correct Answer: C
Section: Volume B
Explanation
Explanation/Reference:
QUESTION 67
You are modifying an existing application that manages employee payroll. The application includes a class named PayrollProcessor. The PayrollProcessor class
connects to a payroll database and processes batches of paychecks once a week.
You need to ensure that the PayrollProcessor class supports iteration and releases database connections after the batch processing completes.
Which two interfaces should you implement? (Each correct answer presents part of the complete solution. Choose two.)
A. IEquatable
B. IEnumerable
C. IDisposable
D. IComparable
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
Correct Answer: BC
Section: Volume B
Explanation
Explanation/Reference:
Explanation:
IEnumerable
IDisposable Interface
Exposes an enumerator, which supports a simple iteration over a non-generic collection.
QUESTION 68
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.
A.
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
B.
C.
D.
Correct Answer: A
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
Section: Volume B
Explanation
Explanation/Reference:
QUESTION 69
You need to create a method that can be called by using a varying number of parameters.
A. Method overloading
B. Derived classes
C. Named parameters
D. Enumeration
E. Interface
F. Lambda expressions
Correct Answer: A
Section: Volume B
Explanation
Explanation/Reference:
Explanation:
Method overloading means creating two or more methods on the same type that differ only in the number or type of parameters but have the same name.
Overloading is one of the most important techniques for improving usability, productivity, and readability of reusable libraries. Overloading on the number of
parameters makes it possible to provide simpler versions of constructors and methods. Overloading on the parameter type makes it possible to use the same
member name for members performing identical operations on a selected set of different types.
QUESTION 70
You are developing an application.
The application contains the following code segment (line numbers are included for reference only):
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
When you run the code, you receive the following error message: "Cannot implicitly convert type 'object' to 'int'. An explicit conversion exists (are you missing a
cast?)."
Correct Answer: C
Section: Volume B
Explanation
Explanation/Reference:
QUESTION 71
You have the following code (line numbers are included for reference only):
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
You need to ensure that if an exception occurs, the exception will be logged.
A. Option A
B. Option B
C. Option C
D. Option D
Correct Answer: B
Section: Volume B
Explanation
Explanation/Reference:
Explanation:
XmlWriterTraceListener
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
Directs tracing or debugging output as XML-encoded data to a TextWriter or to a Stream, such as a FileStream.
TraceListener.TraceEvent Method (TraceEventCache, String, TraceEventType, Int32)
Writes trace and event information to the listener specific output.
Syntax:
[ComVisibleAttribute(false)]
public virtual void TraceEvent(
TraceEventCache eventCache,
string source,
TraceEventType eventType,
int id
)
QUESTION 72
You write the following method (line numbers are included for reference only):
You need to ensure that the method extracts a list of URLs that match the following pattern:
@http://(www\.)?([^\.]+)\.com;
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
A. Option A
B. Option B
C. Option C
D. Option D
Correct Answer: D
Section: Volume B
Explanation
Explanation/Reference:
Explanation:
MatchCollection
Represents the set of successful matches found by iteratively applying a regular expression pattern to the input string.
The collection is immutable (read-only) and has no public constructor. The Regex.Matches method returns a MatchCollection object.
List<T>.Add Method
Adds an object to the end of the List<T>.
QUESTION 73
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.
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
What should you do?
Correct Answer: D
Section: Volume B
Explanation
Explanation/Reference:
Explanation:
The Windows Software Development Kit (SDK) provides several ways to sign an assembly with a strong name:
Using the Assembly Linker (Al.exe) provided by the Windows SDK.
Using assembly attributes to insert the strong name information in your code. You can use either the AssemblyKeyFileAttribute or the
AssemblyKeyNameAttribute, depending on where the key file to be used is located.
Using compiler options such /keyfile or /delaysign in C# and Visual Basic, or the /KEYFILE or /DELAYSIGN linker option in C++. (For information on delay
signing, see Delay Signing an Assembly.)
Note:
A strong name consists of the assembly's identity—its simple text name, version number, and culture information (if provided)—plus a public key and a digital
signature. It is generated from an assembly file (the file that contains the assembly manifest, which in turn contains the names and hashes of all the files that make
up the assembly), using the corresponding private key. Microsoft® Visual Studio® .NET and other development tools provided in the .NET Framework SDK can
assign strong names to an assembly. Assemblies with the same strong name are expected to be identical.
QUESTION 74
You need to store the values in a collection.
A. SortedList
B. Queue
C. ArrayList
D. Hashtable
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
Correct Answer: B
Section: Volume B
Explanation
Explanation/Reference:
QUESTION 75
An application is throwing unhandled NullReferenceException and FormatException errors. The stack trace shows that the exceptions occur in the GetWebResult
() method.
The application includes the following code to parse XML data retrieved from a web service. (Line numbers are included for reference only.)
You need to handle the exceptions without interfering with the existing error-handling infrastructure.
Which two actions should you perform? (Each correct answer presents part of the solution. Choose two.)
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
A. Option A
B. Option B
C. Option C
D. Option D
Correct Answer: AC
Section: Volume B
Explanation
Explanation/Reference:
Explanation:
A: The TryParse method is like the Parse method, except the TryParse method does not throw an exception if the conversion fails. It eliminates the need to use
exception handling to test for a FormatException in the event that s is invalid and cannot be successfully parsed.
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
QUESTION 76
You are developing an application that retrieves patient data from a web service. The application stores the JSON messages returned from the web service in a
string variable named PatientAsJson.
The variable is encoded as UTF-8. The application includes a class named Patient that is defined by the following code:
You need to populate the Patient class with the data returned from the web service.
A.
B.
C.
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
D.
Correct Answer: A
Section: Volume B
Explanation
Explanation/Reference:
QUESTION 77
You are developing a game that allows players to collect from 0 through 1000 coins. You are creating a method that will be used in the game. The method includes
the following code. (Line numbers are included for reference only.)
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
A. Option A
B. Option B
C. Option C
D. Option D
Correct Answer: D
Section: Volume B
Explanation
Explanation/Reference:
QUESTION 78
You have an application that will send confidential information to a Web server.
You need to ensure that the data is encrypted when it is sent across the network.
A. CryptoStream
B. AuthenticatedStream
C. PipeStream
D. NegotiateStream
Correct Answer: A
Section: Volume B
Explanation
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
Explanation/Reference:
QUESTION 79
You are developing a class named EmployeeRoster. The following code implements the EmployeeRoster class. (Line numbers are included for reference only.)
You create the following unit test method to test the EmployeeRoster class implementation:
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
A.
B.
C.
D.
Correct Answer: B
Section: Volume B
Explanation
Explanation/Reference:
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
QUESTION 80
You are developing an application that produces an executable named MyApp.exe and an assembly named MyApp.dll.
You need to ensure that enough debugging information is available for MyApp.exe, so that if the application throws an error in a customer's environment, you can
debug the error in your own development environment.
Correct Answer: B
Section: Volume B
Explanation
Explanation/Reference:
QUESTION 81
You are modifying an existing banking application.
The application includes an Account class and a Customer class. The following code segment defines the classes.
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
You populate a collection named customerCollection with Customer and Account objects by using the following code segment:
You create a largeCustomerAccounts collection to store the Account objects by using the following code segment:
All accounts with a Balance value greater than or equal to 1,000,000 must be tracked.
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
Which code segment should you use?
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
A. Option A
B. Option B
C. Option C
D. Option D
Correct Answer: C
Section: Volume B
Explanation
Explanation/Reference:
QUESTION 82
You have a C# application named App1 that invokes a method in an external assembly named Assembly1. Assembly1 is written in C++ and is natively compile by
using a debug build.
When you debug App1, you do not see any debug information for Assembly1.
You need to ensure that when you debug App1, you see the debug information for Assembly1.
A. On the Debugging page of the configuration properties for the C++ project, set the Debugger Type to Native Only.
B. On the Debugging page of the configuration properties for the C++ project, set the Debugger Type to Mixed.
C. On the Debug page of the project properties for App1, click Enable native code debugging.
D. In the project properties for App1, set the working directory to the same directory as Assembly1.
Correct Answer: B
Section: Volume B
Explanation
Explanation/Reference:
Reference: https://msdn.microsoft.com/en-us/library/kcw4dzyf.aspx
QUESTION 83
You are creating an application that reads from a database.
You need to use different databases during the development phase and the testing phase by using conditional compilation techniques.
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
What should you do?
A. Configure the assembly metadata to use the pre-existing public key for the assembly identity by using the AssemblySignatureKeyAttribute attribute.
B. Disable the strong-name bypass feature of Microsoft .NET Framework in the registry.
C. Configure the Define DEBUG constant setting in Microsoft Visual Studio.
D. Decorate the code by using the [assembly:AssemblyDelaySignAttribute(true)] attribute.
Correct Answer: C
Section: Volume B
Explanation
Explanation/Reference:
Explanation:
Use one debug version to connect to the development database, and a standard version to connect to the live database.
QUESTION 84
You are troubleshooting an application that uses a class named FullName. The class is decorated with the DataContractAttribute attribute. The application
includes the following code. (Line numbers are included for reference only.)
You need to ensure that the entire FullName object is serialized to the memory stream object.
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
A. binary.WriteEndDocument();
B. binary.WriteEndDocumentAsync();
C. binary.WriteEndElementAsync();
D. binary.Flush();
E. binary.WriteEndElement();
F. ms.Close();
G. ms.Flush();
Correct Answer: D
Section: Volume B
Explanation
Explanation/Reference:
Explanation:
Flush() flushes whatever is in the buffer to the underlying streams and also flushes the underlying stream.
We should flush the binary stream with the binary.Flush() command.0
Example:
By default, the DataContractSerializer encodes objects into a stream using a textual representation of XML. However, you can influence the encoding of the XML by
passing in a different writer. The sample creates a binary writer by calling CreateBinaryWriter. It then passes the writer and the record object to the serializer when it
calls WriteObjectContent. Finally, the sample flushes the writer.
References:
https://docs.microsoft.com/en-us/dotnet/api/system.xml.xmldictionarywriter
https://docs.microsoft.com/en-us/dotnet/framework/wcf/samples/datacontractserializer-sample
QUESTION 85
You are creating a console application named App1.
You are developing the following code segment (line numbers are included for reference only):
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
You need to complete the code segment.
The solution must ensure that prices are positive and have two decimal places.
A. Option A
B. Option B
C. Option C
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
D. Option D
Correct Answer: A
Section: Volume B
Explanation
Explanation/Reference:
Explanation:
Contains a positive integer or a floating point number with exactly two characters after the decimal point. Regular expression: \d+(\.\d\d)?
Syntax:
public static bool IsMatch(
string input,
string pattern
)
QUESTION 86
You are creating a console application named Appl.
App1 retrieves data from the Internet by using JavaScript Object Notation (JSON).
You are developing the following code segment (line numbers are included for reference only):
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
You need to ensure that the code validates the JSON string.
A. Option A
B. Option B
C. Option C
D. Option D
Correct Answer: D
Section: Volume B
Explanation
Explanation/Reference:
Explanation:
The JavaScriptSerializer Class Provides serialization and deserialization functionality for AJAX-enabled applications.
The JavaScriptSerializer class is used internally by the asynchronous communication layer to serialize and deserialize the data that is passed between the browser
and the Web server. You cannot access that instance of the serializer. However, this class exposes a public API. Therefore, you can use the class when you want
to work with JavaScript Object Notation (JSON) in managed code.
QUESTION 87
You are evaluating a method that calculates loan interest. The application includes the following code segment. (Line numbers are included for reference only.)
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
When the loanTerm value is 3 and the loanAmount value is 9750, the loanRate must be set to 8.25 percent.
A. Replace line 04 with the following code segment: decimal loanRate = 0.0325m;
B. Replace line 17 with the following code segment: interestAmount = loanAmount * 0.0825m * loanTerm;
C. Replace line 15 with the following code segment: loanRate = 0.0825m;
D. Replace line 07 with the following code segment: loanRate = 0.0825m;
Correct Answer: C
Section: Volume B
Explanation
Explanation/Reference:
QUESTION 88
You are implementing a new method named ProcessData. The ProcessData() method calls a third-party component that performs a long-running operation to
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
retrieve stock information from a web service.
The third-party component uses the IAsyncResult pattern to signal completion of the long-running operation so that the UI can be updated with the new values.
You need to ensure that the calling code handles the long-running operation as a System.Threading.Tasks.Task object to avoid blocking the UI thread.
Which two actions should you perform? Each correct answer presents part of the solution.
Correct Answer: AB
Section: Volume B
Explanation
Explanation/Reference:
Explanation:
A: TaskFactory.FromAsync Method
Creates a Task that represents a pair of begin and end methods that conform to the Asynchronous Programming Model pattern. Overloaded.
Example:
TaskFactory.FromAsync Method (IAsyncResult, Action<IAsyncResult>)
Creates a Task that executes an end method action when a specified IAsyncResult completes.
B: In many scenarios, it is useful to enable a Task<TResult> to represent an external asynchronous operation. TaskCompletionSource<TResult> is provided for this
purpose. It enables the creation of a task that can be handed out to consumers, and those consumers can use the members of the task as they would any other.
However, unlike most tasks, the state of a task created by a TaskCompletionSource is controlled explicitly by the methods on TaskCompletionSource. This enables
the completion of the external asynchronous operation to be propagated to the underlying Task. The separation also ensures that consumers are not able to
transition the state without access to the corresponding TaskCompletionSource.
Note:
System.Threading.Tasks.Task
Represents an asynchronous operation.
QUESTION 89
You are developing an application for a bank. The application includes a method named ProcessLoan that processes loan applications. The ProcessLoan()
method uses a method named CalculateInterest. The application includes the following code:
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
You need to declare a delegate to support the ProcessLoan() method.
A. Option A
B. Option B
C. Option C
D. Option D
Correct Answer: C
Section: Volume B
Explanation
Explanation/Reference:
QUESTION 90
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
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 the goal? Each correct answer presents a complete solution.
A. Option A
B. Option B
C. Option C
D. Option D
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
Correct Answer: AC
Section: Volume B
Explanation
Explanation/Reference:
QUESTION 91
You are developing an application that will process personnel records.
You need to ensure that the application uses the strongest available encryption.
A. System.Security.Cryptography.DES
B. System.Security.Cryptography.Aes
C. System.Security.Cryptography.TripleDES
D. System.Security.Cryptography.RC2
Correct Answer: B
Section: Volume B
Explanation
Explanation/Reference:
QUESTION 92
You develop a class named MyClass. MyClass has a method that uses a COM object.
You need to ensure that when MyClass is instantiated by using the using keyword, the COM object is released at the end of the using scope.
A. ISerializable
B. IDisposable
C. ICloneable
D. IFormattable
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
Correct Answer: B
Section: Volume B
Explanation
Explanation/Reference:
Reference: https://msdn.microsoft.com/en-us/library/system.idisposable(v=vs.110).aspx
QUESTION 93
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:
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.
A. Option A
B. Option B
C. Option C
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
D. Option D
Correct Answer: B
Section: Volume B
Explanation
Explanation/Reference:
QUESTION 94
You are developing an application that uses multiple asynchronous tasks to optimize performance. The application will be deployed in a distributed environment.
You need to retrieve the result of an asynchronous task that retrieves data from a web service. The data will be later being parsed by a separate task.
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
A. Option A
B. Option B
C. Option C
D. Option D
Correct Answer: C
Section: Volume B
Explanation
Explanation/Reference:
QUESTION 95
You are developing an application.
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
When you compile the code, you receive the following syntax error message: "A previous catch clause already catches all exceptions of this or a super type
('System.Exception')."
You need to ensure that the code can be compiled. What should you do?
Correct Answer: A
Section: Volume B
Explanation
Explanation/Reference:
QUESTION 96
You have an application that accesses a Web server named Server1.
You need to download an image named Image1.jpg from Server1 and store the image locally as Filel.jpg.
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
A. Option A
B. Option B
C. Option C
D. Option D
Correct Answer: C
Section: Volume B
Explanation
Explanation/Reference:
QUESTION 97
You are developing an assembly.
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
What should you do?
A. Run the Assembly Linker tool from the Windows Software Development Kit (Windows SDK).
B. Run the Strong Name tool from the Windows Software Development Kit (Windows SDK).
C. Add the AssemblySignatureKeyAttribute attribute the assembly.
D. Add the AssemblyDelaySignAttribute attribute to the assembly.
Correct Answer: D
Section: Volume B
Explanation
Explanation/Reference:
QUESTION 98
You are creating a class by using C#. The class will manage writing log entries to a file.
You have the following code. (Line numbers are included for reference only.)
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
c19 if (disposing)
c20 {
c21 log.Flush();
c22 log.Dispose();
c23 }
c24
c25 }
c26 public void Dispose()
c27 {
c28 Dispose(true);
c29 GC.SupressFinalize(this);
c30 }
c31 }
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
When you run the text, you receive the following error message: "System.ObjectDisposedException: ‘Cannot write to a closed TextWritter."
You need to ensure that LogWriter closes the log file properly without raising an exception.
Which three actions should you perform? Each correct answer presents part of the solution.
Explanation/Reference:
References: https://docs.microsoft.com/en-us/dotnet/standard/design-guidelines/dispose-pattern
QUESTION 99
You write the following method (line numbers are included for reference only):
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
You need to ensure that the method extracts a list of URLs that match the following pattern:
@http://(www\.)?([^\.]+)\.com;
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
A. Option A
B. Option B
C. Option C
D. Option D
Correct Answer: C
Section: Volume B
Explanation
Explanation/Reference:
Explanation:
MatchCollection
Represents the set of successful matches found by iteratively applying a regular expression pattern to the input string.
The collection is immutable (read-only) and has no public constructor. The Regex.Matches method returns a MatchCollection object.
List<T>.Add Method
Adds an object to the end of the List<T>.
Incorrect Answers:
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
B: The MatchCollection.GetEnumerator method returns an enumerator that iterates through a collection. However, To iterate through the members of the collection,
you should use the collection iteration (foreach) instead of retrieving the enumerator that is returned by the GetEnumerator method.
References: https://msdn.microsoft.com/en-us/library/system.text.regularexpressions.matchcollection(v=vs.110).aspx
QUESTION 100
You have the following code:
You need to retrieve all of the numbers from the items variable that are greater than 80.
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
A. Option A
B. Option B
C. Option C
D. Option D
Correct Answer: B
Section: Volume B
Explanation
Explanation/Reference:
Explanation:
Enumerable.Where<TSource> Method (IEnumerable<TSource>, Func<TSource, Boolean>)
Filters a sequence of values based on a predicate.
Example:
List<string> fruits =
new List<string> { "apple", "passionfruit", "banana", "mango",
"orange", "blueberry", "grape", "strawberry" };
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
IEnumerable<string> query = fruits.Where(fruit => fruit.Length < 6);
apple
mango
grape
*/
QUESTION 101
You are developing an application that uses several objects. The application includes the following code segment. (Line numbers are included for reference only.)
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
A. Option A
B. Option B
C. Option C
D. Option D
Correct Answer: B
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
Section: Volume B
Explanation
Explanation/Reference:
Explanation:
Use the == operator to compare values and in this case also use the null literal.
QUESTION 102
You are developing a class named Account that will be used by several applications.
The applications that will consume the Account class will make asynchronous calls to the Account class to execute several different methods.
You need to ensure that only one call to the methods is executed at a time.
A. sealed
B. protected
C. checked
D. lock
Correct Answer: D
Section: Volume B
Explanation
Explanation/Reference:
QUESTION 103
You are developing an application by using C#. The application will write events to an event log. You plan to deploy the application to a server.
You create an event source named MySource and a custom log named MyLog on the server.
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
A. Option A
B. Option B
C. Option C
D. Option D
Correct Answer: D
Section: Volume B
Explanation
Explanation/Reference:
QUESTION 104
You plan to store passwords in a Windows Azure SQL Database database.
You need to ensure that the passwords are stored in the database by using a hash algorithm,
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
Which cryptographic algorithm should you use?
A. ECDSA
B. RSA-768
C. AES-256
D. SHA-256
Correct Answer: D
Section: Volume B
Explanation
Explanation/Reference:
QUESTION 105
You need to write a console application that meets the following requirements:
If the application is compiled in Debug mode, the console output must display Entering debug mode.
If the application is compiled in Release mode, the console output must display Entering release mode.
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
A. Option A
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
B. Option B
C. Option C
D. Option D
Correct Answer: B
Section: Volume B
Explanation
Explanation/Reference:
Explanation:
When the C# compiler encounters an #if directive, followed eventually by an #endif directive, it will compile the code between the directives only if the specified
symbol is defined. Unlike C and C++, you cannot assign a numeric value to a symbol; the #if statement in C# is Boolean and only tests whether the symbol has
been defined or not. For example,
#define DEBUG
// ...
#if DEBUG
Console.WriteLine("Debug version");
#endif
QUESTION 106
You have the following class (line numbers are included for reference only):
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
ServiceProxy is a proxy for a web service. Calls to the Update method can take up to five seconds. The Test class is the only class the uses Class1.
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
You run the Execute method three times, and you receive the following results:
213
312
231
You need to ensure that each value is appended to the Value property in the order that the Modify methods are invoked.
A.
B.
C.
D.
Correct Answer: B
Section: Volume B
Explanation
Explanation/Reference:
QUESTION 107
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
You are developing a method named GetHash that will return a hash value for a file. The method includes the following code. (Line numbers are included for
reference only.)
You need to return the cryptographic hash of the bytes contained in the fileBytes variable.
A. Option A
B. Option B
C. Option C
D. Option D
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
Correct Answer: A
Section: Volume B
Explanation
Explanation/Reference:
QUESTION 108
You are developing an application that includes the following code segment:
You need to implement the Open() method of each interface in a derived class named UseResources and call the Open() method of each interface.
Which two code segments should you use? Each correct answer presents part of the solution.
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
A. Option A
B. Option B
C. Option C
D. Option D
E. Option E
F. Option F
Correct Answer: AC
Section: Volume B
Explanation
Explanation/Reference:
Explanation:
An interface contains only the signatures of methods, properties, events or indexers. A class or struct that implements the interface must implement the members
of the interface that are specified in the interface definition.
Example:
interface ISampleInterface
{
void SampleMethod();
}
QUESTION 109
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
You are implementing a method named ProcessData that performs a long-running task. The ProcessData() method has the following method signature:
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 ProcessData() method performs the required actions.
A. if (token.IsCancellationRequested)return;
B. throw new AggregateException();
C. token.ThrowIfCancellationRequested();
D. source.Cancel();
Correct Answer: C
Section: Volume B
Explanation
Explanation/Reference:
QUESTION 110
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):
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
At which line should you insert the code?
A. 01
B. 03
C. 05
D. 07
Correct Answer: A
Section: Volume B
Explanation
Explanation/Reference:
QUESTION 111
You are implementing a method named GetValidPhoneNumbers. The GetValidPhoneNumbers() method processes a list of string values that represent
phone numbers.
The GetValidPhoneNumbers() method must return only phone numbers that are in a valid format.
Which two code segments can you use to achieve this goal? (Each correct answer presents a complete solution. Choose two.)
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
A. Option A
B. Option B
C. Option C
D. Option D
Correct Answer: AB
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
Section: Volume B
Explanation
Explanation/Reference:
Explanation:
Regex.Matches
Searches an input string for all occurrences of a regular expression and returns all the matches.
MatchCollection
Represents the set of successful matches found by iteratively applying a regular expression pattern to the input string.
The collection is immutable (read-only) and has no public constructor. The Regex.Matches method returns a MatchCollection object.
List<T>.Add Method
Adds an object to the end of the List<T>.
QUESTION 112
You are creating an application that reads from a database.
You need to use different databases during the development phase and the testing phase by using conditional compilation techniques.
Correct Answer: C
Section: Volume B
Explanation
Explanation/Reference:
Explanation:
Use one debug version to connect to the development database, and a standard version to connect to the live database.
QUESTION 113
You are creating a class named Loan.
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
You need to implement the rate member to meet the requirements.
Correct Answer: B
Section: Volume B
Explanation
Explanation/Reference:
QUESTION 114
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.
Correct Answer: B
Section: Volume B
Explanation
Explanation/Reference:
Explanation:
The Windows Software Development Kit (SDK) provides several ways to sign an assembly with a strong name:
Using the Assembly Linker (Al.exe) provided by the Windows SDK.
Using assembly attributes to insert the strong name information in your code. You can use either the AssemblyKeyFileAttribute or the
AssemblyKeyNameAttribute, depending on where the key file to be used is located.
Using compiler options such /keyfile or /delaysign in C# and Visual Basic, or the /KEYFILE or /DELAYSIGN linker option in C++. (For information on delay
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
signing, see Delay Signing an Assembly.)
Note:
A strong name consists of the assembly's identity—it’s simple text name, version number, and culture information (if provided)—plus a public key and a digital
signature. It is generated from an assembly file (the file that contains the assembly manifest, which in turn contains the names and hashes of all the files that make
up the assembly), using the corresponding private key. Microsoft® Visual Studio® .NET and other development tools provided in the .NET Framework SDK can
assign strong names to an assembly. Assemblies with the same strong name are expected to be identical.
QUESTION 115
You are creating a console application named App1.
App1 retrieves data from the Internet by using JavaScript Object Notation (JSON).
You are developing the following code segment (line numbers are included for reference only):
You need to ensure that the code validates the JSON string.
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
A. Option A
B. Option B
C. Option C
D. Option D
Correct Answer: D
Section: Volume B
Explanation
Explanation/Reference:
Explanation:
The JavaScriptSerializer Class Provides serialization and deserialization functionality for AJAX-enabled applications.
The JavaScriptSerializer class is used internally by the asynchronous communication layer to serialize and deserialize the data that is passed between the browser
and the Web server. You cannot access that instance of the serializer. However, this class exposes a public API. Therefore, you can use the class when you want
to work with JavaScript Object Notation (JSON) in managed code.
QUESTION 116
You are developing an application that includes methods named EvaluateLoan, ProcessLoan, and FundLoan. The application defines build configurations named
TRIAL, BASIC, and ADVANCED.
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
The BASIC build configuration must run all three methods.
The ADVANCED build configuration must run only the EvaluateLoan() and ProcessLoan() methods.
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
A. Option A
B. Option B
C. Option C
D. Option D
Correct Answer: C
Section: Volume B
Explanation
Explanation/Reference:
QUESTION 117
You are creating an application that processes a list of numbers.
The application must define a method that queries the list and displays a subset of the numbers to the user. The method must not update the list.
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
A. Option A
B. Option B
C. Option C
D. Option D
Correct Answer: C
Section: Volume B
Explanation
Explanation/Reference:
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
QUESTION 118
You have an assembly named Assembly named Assembly1 that is written in C#.
Your company plans to sell Assembly =1 to customers. The customers might debug Assembly1.
You need to minimize the amount of information contained within the debug symbols that are shipped with Assembly1.
Correct Answer: C
Section: Volume B
Explanation
Explanation/Reference:
Reference: https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/preprocessor-directives/preprocessor-define
QUESTION 119
You are debugging a 64-bit C# application.
Users report System.OutOfMemoryException exceptions. The system is attempting to use arrays larger than 2 GB in size.
You need to ensure that the application can use arrays larger than 2 GB.
A. Add the /3GB switch to the boot.ini file for the operating system.
B. Set the IMAGE_FILE_LARGE_ADDRESS_AWARE flag in the image header for the application executable file.
C. Set the value of the gcAllowVeryLargeObjects property to true in the application configuration file.
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
https://www.gratisexam.com/
D. Set the value of the user-mode virtual address space setting for the operating system to MAX.
Correct Answer: C
Section: Volume B
Explanation
Explanation/Reference:
QUESTION 120
You develop an application by using C#. The application counts the number of times a specific word appears within a set of text files. The application includes the
following code. (Line numbers are included for reference only.)
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
You have the following requirements:
Populate the _wordCounts object with a list of words and the number of occurrences of each word.
Ensure that updates to the ConcurrentDictionary object can happen in parallel.
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
A. Option A
B. Option B
C. Option C
D. Option D
Correct Answer: A
Section: Volume B
Explanation
Explanation/Reference:
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
QUESTION 121
You are evaluating a method that calculates loan interest. The application includes the following code segment. (Line numbers are included for reference only.)
When the loanTerm value is 5 and the loanAmount value is 4500, the loanRate must be set to 6.5 percent.
Correct Answer: A
Section: Volume B
Explanation
Explanation/Reference:
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
QUESTION 122
You are developing an application that will use multiple asynchronous tasks to optimize performance.
You create three tasks by using the following code segment. (Line numbers are included for reference only.)
You need to ensure that the ProcessTasks() method waits until all three tasks complete before continuing.
A. Task.WaitFor(3);
B. tasks.Yield();
C. tasks.WaitForCompletion();
D. Task.WaitAll(tasks);
Correct Answer: D
Section: Volume B
Explanation
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
Explanation/Reference:
QUESTION 123
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.
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
B.
C.
D.
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
E.
F.
Correct Answer: CD
Section: Volume B
Explanation
Explanation/Reference:
Explanation:
C:
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.
QUESTION 124
You have the following class definition.
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
You discover that when you execute the following code, the SpawnTasks method enters an infinite loop.
You need to prevent the SpawnTasks method from entering an infinite loop.
Which two changes should you make to the code? Each correct answer presents part of the solution.
A. Add a property to the ProcessManagement class. Modify the property to allow only positive values to be stored in the DegreeOfParallelism member
variable.
B. Add a property to the ProcessManagement class. Modify the property to allow only positive values to be stored in the NumberOfTasks member variable.
C. Change the accessor of the ProcessManagement class to internal.
D. Change the accessor of the DegreeOfParallelism member variable to private.
E. Change the accessor of the SpawnTasks method to private.
Correct Answer: AB
Section: Volume B
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
Explanation
Explanation/Reference:
QUESTION 125
You are implementing a method named ProcessFile that retrieves data files from web servers and FTP servers. The ProcessFile() method has the following
method signature:
Each time the ProcessFile() method is called, it must retrieve a unique data file and then save the data file to disk.
You need to complete the implementation of the ProcessFile() method. Which code segment should you use?
A.
B.
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
C.
D.
Correct Answer: D
Section: Volume B
Explanation
Explanation/Reference:
Explanation:
WebRequest.Create Method (Uri)
Initializes a new WebRequest instance for the specified URI scheme.
Example:
1. To request data from a host server
Create a WebRequest instance by calling Create with the URI of the resource.
C#
WebRequest request = WebRequest.Create("http://www.contoso.com/");
2. Set any property values that you need in the WebRequest. For example, to enable authentication, set the Credentials property to an instance of the
NetworkCredential class.
C#
request.Credentials = CredentialCache.DefaultCredentials;
3. To send the request to the server, call GetResponse. The actual type of the returned WebResponse object is determined by the scheme of the requested URI.
C#
WebResponse response = request.GetResponse();
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
4. To get the stream containing response data sent by the server, use the GetResponseStream method of the WebResponse.
C#
Stream dataStream = response.GetResponseStream ();
QUESTION 126
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.
Correct Answer: A
Section: Volume B
Explanation
Explanation/Reference:
Explanation:
The Windows Software Development Kit (SDK) provides several ways to sign an assembly with a strong name:
(A) Using assembly attributes to insert the strong name information in your code. You can use either the AssemblyKeyFileAttribute or the
AssemblyKeyNameAttribute, depending on where the key file to be used is located.
Using the Assembly Linker (Al.exe) provided by the Windows SDK.
Using compiler options such /keyfile or /delaysign in C# and Visual Basic, or the /KEYFILE or /DELAYSIGN linker option in C++. (For information on delay
signing, see Delay Signing an Assembly.)
QUESTION 127
You are modifying an existing application.
The application includes a Loan class and a Customer class. The following code segment defines the classes.
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
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:
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
All loans with an Amount value greater than or equal to 4000 must be tracked.
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
A. Option A
B. Option B
C. Option C
D. Option D
Correct Answer: D
Section: Volume B
Explanation
Explanation/Reference:
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.
QUESTION 128
You have the following code. (Line numbers are included for reference only.)
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
You need to ensure that B_Products contain all of the products that start with the letter “B”.
A. Option A
B. Option B
C. Option C
D. Option D
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
Correct Answer: D
Section: Volume B
Explanation
Explanation/Reference:
Explanation:
Simply select the product items.
QUESTION 129
You have the following code:
You need to retrieve all of the numbers from the items variable that are greater than 80.
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
A. Option A
B. Option B
C. Option C
D. Option D
Correct Answer: B
Section: Volume B
Explanation
Explanation/Reference:
Explanation:
Example: All number larger than 15 from a list using the var query = from num in numbers... contstruct:
QUESTION 130
You have the following code. (Line numbers are included for reference only).
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
You need to complete the WriteTextAsync method. The solution must ensure that the code is not blocked while the file is being written.
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
A. Option A
B. Option B
C. Option C
D. Option D
Correct Answer: D
Section: Volume B
Explanation
Explanation/Reference:
Explanation:
await sourceStream.WriteAsync(encodedText, 0, encodedText.Length);
The following example has the statement await sourceStream.WriteAsync(encodedText, 0, encodedText.Length);, which is a contraction of the following two
statements:
Example: The following example writes text to a file. At each await statement, the method immediately exits. When the file I/O is complete, the method resumes at
the statement that follows the await statement. Note that the async modifier is in the definition of methods that use the await statement.
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
string text = "Hello World\r\n";
Reference: Using Async for File Access (C# and Visual Basic)
https://msdn.microsoft.com/en-us/library/jj155757.aspx
QUESTION 131
You are developing an application that contains a class named TheaterCustomer and a method named ProcessTheaterCustomer. The
ProcessTheaterCustomer() method accepts a TheaterCustomer object as the input parameter.
A. Create a System.Collections.Queue collection. Use the Enqueue() method to add TheaterCustomer objects to the collection. Use the Dequeue()
method to pass the objects to the ProcessTheaterCustomer() method.
B. Create a System.Collections.ArrayList collection. Use the Insert() method to add TheaterCustomer objects to the collection. Use the Remove()
method to pass the objects to the ProcessTheaterCustomer() method.
C. Create a System.Collections.Stack collection. Use the Push() method to add TheaterCustomer objects to the collection. Use the Pop() method to pass
the objects to the ProcessTheaterCustomer() method.
D. Create a System.Collections.Queue collection. Use the Enqueue() method to add TheaterCustomer objects to the collection. Use the Peek() method to
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
pass the objects to the ProcessTheaterCustomer() method.
Correct Answer: C
Section: Volume B
Explanation
Explanation/Reference:
Explanation:
A stack is the appropriate collection here. In computer science, a stack or LIFO (last in, first out) is an abstract data type that serves as a collection of elements,
with two principal operations: push, which adds an element to the collection, and pop, which removes the last element that was added.
Reference: https://en.wikipedia.org/wiki/Stack_(abstract_data_type)
QUESTION 132
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.
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
A. Option A
B. Option B
C. Option C
D. Option D
Correct Answer: B
Section: Volume B
Explanation
Explanation/Reference:
Explanation:
The following list provides the main features of a static class:
Contains only static members.
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
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
QUESTION 133
You have the following C# code.
A. -4
B. -3
C. 2
D. 3
E. 7
Correct Answer: C
Section: Volume B
Explanation
Explanation/Reference:
QUESTION 134
You write the following method (line numbers are included for reference only):
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
You need to ensure that the method extracts a list of URLs that match the following pattern:
@http://(www\.)?([^\.]+)\.com;
A. Option A
B. Option B
C. Option C
D. Option D
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
Correct Answer: A
Section: Volume B
Explanation
Explanation/Reference:
Explanation:
The MatchCollection.GetEnumerator method returns an enumerator that iterates through a collection.
Note:
The MatchCollection Class represents the set of successful matches found by iteratively applying a regular expression pattern to the input string.
QUESTION 135
You are creating an application that reads from a database.
You need to use different databases during the development phase and the testing phase by using conditional compilation techniques.
Correct Answer: B
Section: Volume B
Explanation
Explanation/Reference:
Explanation:
You can specify the compiler settings for your application in several ways:
The property pages
The command line
#CONST (for Visual Basic) and #define (for C#)
Note: You can have either the Trace or Debug conditional attribute turned on for a build, or both, or neither. Thus, there are four types of build: Debug, Trace, both,
or neither. Some release builds for production deployment might contain neither; most debugging builds contain both.
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
Reference: How to: Compile Conditionally with Trace and Debug
https://msdn.microsoft.com/en-us/library/64yxa344(v=vs.110).aspx
QUESTION 136
You are creating a console application named Appl.
App1 retrieves data from the Internet by using JavaScript Object Notation (JSON).
You are developing the following code segment (line numbers are included for reference only):
You need to ensure that the code validates the JSON string.
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
A. Option A
B. Option B
C. Option C
D. Option D
Correct Answer: B
Section: Volume B
Explanation
Explanation/Reference:
Explanation:
JavaScriptSerializer().Deserialize
Converts the specified JSON string to an object of type T.
Example:
string json = File.ReadAllText(Environment.CurrentDirectory + @"\JSON.txt");
QUESTION 137
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.
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
The following code implements the methods. (Line numbers are included for reference only.)
What are two possible ways to achieve this goal? Each correct answer presents a complete solution.
A.
B.
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
C.
D.
E.
F.
G.
Correct Answer: DG
Section: Volume B
Explanation
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
Explanation/Reference:
Explanation:
D: Also, it's worth pointing out that you can use [Conditional("DEBUG")] attribute on methods that return void to have them only executed if a certain symbol is
defined. The compiler would remove all calls to those methods if the symbol is not defined:
[Conditional("DEBUG")]
void PrintLog() {
Console.WriteLine("Debug info");
}
void Test() {
PrintLog();
}
G: When the C# compiler encounters an #if directive, followed eventually by an #endif directive, it will compile the code between the directives only if the specified
symbol is defined. Unlike C and C++, you cannot assign a numeric value to a symbol; the #if statement in C# is Boolean and only tests whether the symbol has
been defined or not. For example,
#define DEBUG
#if DEBUG
Console.WriteLine("Debug version");
#endif
References:
http://stackoverflow.com/questions/2104099/c-sharp-if-then-directives-for-debug-vs-release
QUESTION 138
You have a class named Customer and a variable named customers.
You need to test whether the customers variable is a generic list of Customer objects.
Which line of code should you use?
A.
B.
C.
D.
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
Correct Answer: D
Section: Volume B
Explanation
Explanation/Reference:
Explanation:
If you want to check if it's an instance of a generic type:
return list.GetType().IsGenericType;
If you want to check if it's a generic List<T>:
QUESTION 139
You have a C# application.
You need to identify whether there is enough available memory when the application starts.
A. OutOfmemoryException
B. MemoryStream
C. PerformanceCounter
D. DiagnosticsConfigurationHandler
Correct Answer: C
Section: Volume B
Explanation
Explanation/Reference:
QUESTION 140
You plan to create a list of customers named customers. Each customer will have a name and a key. The name and key will be strings.
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
You will use the following code to retrieve customers from the list.
customers[aKey].toString();
You need to identify which class must be used to declare the customers list. The solution must ensure that each key is unique.
A. ArrayList
B. Dictionary
C. List
D. Array
Correct Answer: B
Section: Volume B
Explanation
Explanation/Reference:
QUESTION 141
You are developing a Windows Forms (WinForms) application. The application displays a TreeView that has 1,000 nodes.
You need to ensure that if a user expands a node, and then collapses the TreeView, the node object is kept in memory unless the Garbage Collector requires
additional memory.
A. GC
B. Handle
C. Cache
D. WeakReference
Correct Answer: D
Section: Volume B
Explanation
Explanation/Reference:
References: https://msdn.microsoft.com/en-us/library/ms404247.aspx
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
QUESTION 142
You have the following line of code.
You need to create an object named obj that has a type of type1.
A. Option A
B. Option B
C. Option C
D. Option D
Correct Answer: B
Section: Volume B
Explanation
Explanation/Reference:
QUESTION 143
You need to write a console application that meets the following requirements:
If the application is compiled in Debug mode, the console output must display Entering debug mode.
If the application is compiled in Release mode, the console output must display Entering release mode.
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
A.
B.
C.
D.
Correct Answer: B
Section: Volume B
Explanation
Explanation/Reference:
QUESTION 144
You plan to debug an application remotely by using Microsoft Visual Studio 2013.
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
You set a breakpoint in the code.
When you compile the application, you get the following error message: “The breakpoint will not currently be hit. No symbols have been loaded for this document.”
You need to ensure that you can debug the application remotely.
Correct Answer: A
Section: Volume B
Explanation
Explanation/Reference:
References: https://msdn.microsoft.com/en-us/library/y7f5zaaa.aspx
QUESTION 145
You are creating an assembly named Assembly1 by using the Class Library project template in Microsoft Visual Studio. Assembly1 is used by a C# application
named App1.
You do not have access to the Visual Studio project for App1.
Correct Answer: C
Section: Volume B
Explanation
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
Explanation/Reference:
Reference: https://msdn.microsoft.com/en-us/library/2wcdezs5.aspx
QUESTION 146
You are creating an application that reads from a database.
You need to use different databases during the development phase and the testing phase by using conditional compilation techniques.
Correct Answer: A
Section: Volume B
Explanation
Explanation/Reference:
QUESTION 147
You are developing an application.
You need to declare a delegate for a method that accepts a string as a parameter, and then returns a string.
A. Func<string, string>
B. Action< string, string>
C. Func< string>
D. Action< string>
Correct Answer: A
Section: Volume B
Explanation
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
Explanation/Reference:
QUESTION 148
You have the following code.
You need to remove all of the data from the myData list.
Correct Answer: A
Section: Volume B
Explanation
Explanation/Reference:
QUESTION 149
Note: This question is part of a series of questions that present the same scenario. Each question in the series contains a unique solution that might
meet the stated goals. Some question sets might have more than one correct solution, while others might not have a correct solution.
After you answer a question in this section, you will NOT be able to return to it. As a result, these questions will not appear in the review screen.
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
You have the following C# code. (Line numbers are included for reference only.)
You need the foreach loop to display a running total of the array elements, as shown in the following list.
1
3
6
10
15
A. Yes
B. No
Correct Answer: B
Section: Volume B
Explanation
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
Explanation/Reference:
Explanation:
Console.WriteLine is repeated twice.
QUESTION 150
You need to create a method that can be called by using a varying number of parameters.
A. enumeration
B. Language-Integrated Query (LINQ) query expressions
C. interface
D. optional parameters
E. named parameters
Correct Answer: D
Section: Volume B
Explanation
Explanation/Reference:
QUESTION 151
You are developing a C# application named Application1 by using Microsoft Visual Studio 2017.
You plan to compare the memory usage between different builds of Application1.
A. IntelliTrace
B. Memory Usage from Performance Profiler
C. Performance Wizard from Performance Profiler
D. Code Analysis
Correct Answer: B
Section: Volume B
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
Explanation
Explanation/Reference:
Reference: https://msdn.microsoft.com/en-US/library/dn645469(VS.140).aspx
QUESTION 152
You are developing an application that retrieves customer data from a web service. The application stores the JSON messages returned from the web service in a
string variable named CustomerAsJson. The variable is encoded as UTF-8. The application includes a class named Customer that is defined by the following code:
You need to populate the Customer class with the data returned from the web service.
A.
B.
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
C.
D.
Correct Answer: B
Section: Volume B
Explanation
Explanation/Reference:
QUESTION 153
Note: This question is part of a series of questions that present the same scenario. Each question in the series contains a unique solution that might
meet the stated goals. Some question sets might have more than one correct solution, while others might not have a correct solution.
After you answer a question in this section, you will NOT be able to return to it. As a result, these questions will not appear in the review screen.
You have the following C# code. (Line numbers are included for reference only.)
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
You need the foreach loop to display a running total of the array elements, as shown in the following output.
1
3
6
10
15
A. Yes
B. No
Correct Answer: B
Section: Volume B
Explanation
Explanation/Reference:
QUESTION 154
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
Note: This question is part of a series of questions that present the same scenario. Each question in the series contains a unique solution that might
meet the stated goals. Some question sets might have more than one correct solution, while others might not have a correct solution.
After you answer a question in this section, you will NOT be able to return to it. As a result, these questions will not appear in the review screen.
You have the following C# code. (Line numbers are included for reference only.)
You need the foreach loop to display a running total of the array elements, as shown in the following output.
1
3
6
10
15
A. Yes
B. No
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
Correct Answer: A
Section: Volume B
Explanation
Explanation/Reference:
QUESTION 155
You are developing a C# application. The application includes the following code segment. (Line numbers are included for reference only.)
The application fails at line 17 with the following error message: "An item with the same key has already been added."
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
A. Option A
B. Option B
C. Option C
D. Option D
Correct Answer: B
Section: Volume B
Explanation
Explanation/Reference:
Explanation:
Use if statement with ContainsKey method to check if dictionary already contains the specified key.
References:
https://msdn.microsoft.com/en-us/library/kw5aaea4(v=vs.110).aspx
https://www.c-sharpcorner.com/UploadFile/mahesh/how-to-find-a-key-in-a-dictionary-with-C-Sharp/
QUESTION 156
You have two assemblies named Assembly1 and Assembly2 that are written in C#. Assembly1 loads Assembly2 by executing the following code.
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
You create a new project in Microsoft Visual Studio to build a new assembly that will replace Assembly2. The new assembly has the same name and version as
the original Assembly2 assembly.
Correct Answer: D
Section: Volume B
Explanation
Explanation/Reference:
Reference:
https://docs.microsoft.com/en-us/dotnet/framework/app-domains/how-to-sign-an-assembly-with-a-strong-name
https://docs.microsoft.com/en-us/dotnet/framework/tools/al-exe-assembly-linker
QUESTION 157
Note: This question is part of a series of questions that present the same scenario. Each question in the series contains a unique solution that might
meet the stated goals. Some question sets might have more than one correct solution, while others might not have a correct solution.
After you answer a question in this section, you will NOT be able to return to it. As a result, these questions will not appear in the review screen.
You have the following C# code. (Line numbers are included for reference only.)
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
You need the foreach loop to display a running total of the array elements, as shown in the following list.
1
3
6
10
15
A. Yes
B. No
Correct Answer: B
Section: Volume B
Explanation
Explanation/Reference:
QUESTION 158
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
An application contains code that measures reaction times. The code counts on a thread separate from the user interface. The application includes the following
code. (Line numbers are included for reference only.)
You need to ensure that the application cancels counting when the user presses the Enter key.
A. cancellationTokenSource.Dispose();
B. cancellationTokenSource.Token.Register(() => cancellationTokenSource.Cancel());
C. cancellationTokenSource.Cancel();
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
D. cancellationTokenSource.IsCancellationRequested = true;
Correct Answer: A
Section: Volume B
Explanation
Explanation/Reference:
Explanation:
CancellationTokenSource.Dispose() releases all resources used by the current instance of the CancellationTokenSource class.
Reference:
https://docs.microsoft.com/en-us/previous-versions/windows/silverlight/dotnet-windows-silverlight/dd321629(v=vs.95)
QUESTION 159
You have a collection of Product objects named products. Each Product has a category.
A. Group
B. Where
C. Aggregate
D. Select
Correct Answer: B
Section: Volume B
Explanation
Explanation/Reference:
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
QUESTION 160
You have the following C# code that manipulates a string.
A. This is a sentence.
B. Thrandom random a random sentence.
C. This is a is sentence.
D. This random sentence.
Correct Answer: D
Section: Volume B
Explanation
Explanation/Reference:
Reference: https://docs.microsoft.com/en-us/dotnet/api/system.string.substring?view=netframework-4.7.2
QUESTION 161
You need to write a method that retrieves data from a Microsoft Access 2013 database. The method must meet the following requirements:
It must be read-only.
You must be able to use the data before the entire data set is retrieved.
You must minimize the amount of system overhead and the amount of memory usage.
A. DbDataAdapter
B. DbDataReader
C. typed DataSet
D. OleDbDataAdapter
Correct Answer: B
Section: Volume B
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
Explanation
Explanation/Reference:
Explanation:
The DbDataReader class reads a forward-only stream of rows from a data source.
QUESTION 162
You are creating an application that reads from a database.
You need to use different databases during the development phase and the testing phase by using conditional compilation techniques.
A. Configure the assembly metadata to use the pre-existing public key for the assembly identity by using the AssemblySignatureKeyAttribute attribute.
B. Decorate the code by using the [DebuggerDisplay(“Mydebug”)] attribute.
C. Decorate the code by using the [assembly:AssemblyDelaySignAttribute(true)] attribute.
D. Configure the Define DEBUG constant setting in Microsoft Visual Studio.
Correct Answer: D
Section: Volume B
Explanation
Explanation/Reference:
QUESTION 163
A public class named Message has a method named SendMessage. The SendMessage() method is leaking memory.
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
A try…catch block in the SendMessage() method does not release resources after the method returns.
You need to ensure that the method releases all resources properly.
Correct Answer: A
Section: Volume B
Explanation
Explanation/Reference:
Reference: https://docs.microsoft.com/en-us/dotnet/api/system.gc.collect?redirectedfrom=MSDN&view=netframework-4.7.2#System_GC_Collect
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
QUESTION 164
You have an assembly named Assembly1 that is written in C#. Assembly1 has a method named Method1.
You add a new method named Method2 to Assembly1. Method2 is a newer version of Method1 and must be used by applications in the future.
You need to ensure that if a developer builds a project that uses Method1, the developer is notified that Method1 is deprecated.
A. Set an #if DEPRECATED preprocessor directive above Method1. Set a #endif preprocessor directive after Method1.
B. Set a #pragma warning disable preprocessor inside of Method1.
C. Mark Method1 with an ObsoleteAttribute attribute.
D. Modify Method1 to return an exception.
Correct Answer: C
Section: Volume B
Explanation
Explanation/Reference:
Explanation:
ObsoleteAttribute is applicable to all program elements except assemblies, modules, parameters, and return values. Marking an element as obsolete informs users
that the element will be removed in future versions of the product.
Reference:
https://docs.microsoft.com/en-us/dotnet/api/system.obsoleteattribute?view=netframework-4.7.2
QUESTION 165
You are debugging an application that calculates loan interest. The application includes the following code. Line numbers are included for reference only.
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2
The debugger must break execution within the Calculatelnterest() method when the loanAmount variable is greater than zero.
The release version of the code must not be impacted by any changes.
Correct Answer: C
Section: Volume B
Explanation
Explanation/Reference:
Explanation:
By default, the Debug.Assert method works only in debug builds.
Incorrect Answers:
D: Use the Trace.Assert method if you want to do assertions in release builds.
Reference:
https://docs.microsoft.com/en-us/dotnet/api/system.diagnostics.debug.assert
https://www.gratisexam.com/
https://www.gratisexam.com/
885CB989129A5F974833949052CFB2F2