Q1. - (Topic 2)
You are developing an application that includes methods named ConvertAmount and TransferFunds.
You need to ensure that the precision and range of the value in the amount variable is not lost when the TransferFunds() method is called.
Which code segment should you use?
A. Option A
B. Option B
C. Option C
D. Option D
Answer: C
Explanation: Simply use float for the TransferFunds parameter.
Note:
* The float keyword signifies a simple type that stores 32-bit floating-point values.
* The double keyword signifies a simple type that stores 64-bit floating-point values
Q2. - (Topic 1)
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. Choose two.)
A. AssemblyKeyNameAttribute
B. ObfuscateAssemblyAttribute
C. AssemblyDelaySignAttribute
D. AssemblyKeyFileAttribute
Answer: C,D
Explanation:
http://msdn.microsoft.com/en-us/library/t07a3dye(v=vs.110).aspx
Q3. - (Topic 1)
You are implementing a method named FloorTemperature that performs conversions between value types and reference types. The following code segment implements the method. (Line numbers are included for reference only.)
You need to ensure that the application does not throw exceptions on invalid conversions. Which code segment should you insert at line 04?
A. int result = (int)degreesRef;
B. int result = (int)(double)degreesRef;
C. int result = degreesRef;
D. int result = (int)(float)degreesRef;
Answer: D
Q4. - (Topic 1)
You are developing an application that uses the Microsoft ADO.NET Entity Framework to retrieve order information from a Microsoft SQL Server database. The application includes the following code. (Line numbers are included for reference only.)
The application must meet the following requirements:
. Return only orders that have an OrderDate value other than null.
. Return only orders that were placed in the year specified in the OrderDate property or in a later year.
You need to ensure that the application meets the requirements.
Which code segment should you insert at line 08?
A. Where order.OrderDate.Value != null && order.OrderDate.Value.Year > = year
B. Where order.OrderDate.Value = = null && order.OrderDate.Value.Year = = year
C. Where order.OrderDate.HasValue && order.OrderDate.Value.Year = = year
D. Where order.OrderDate.Value.Year = = year
Answer: A
Explanation: *For the requirement to use an OrderDate value other than null use: OrderDate.Value != null
*For the requirement to use an OrderDate value for this year or a later year use: OrderDate.Value>= year
Q5. - (Topic 2)
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.
Which keyword should you use?
A. sealed
B. protected
C. checked
D. lock
Answer: D
Q6. - (Topic 2)
You are testing an application. The application includes methods named CalculateInterest and LogLine. The CalculateInterest() method calculates loan interest. The LogLine() method sends diagnostic messages to a console window.
The following code implements the methods. (Line numbers are included for reference only.)
You have the following requirements:
. The CalculateInterest() method must run for all build configurations. . The LogLine() method must run only for debug builds.
You need to ensure that the methods run correctly.
What are two possible ways to achieve this goal? (Each correct answer presents a complete solution. Choose two.)
A. Insert the following code segment at line 01:
#region DEBUG
Insert the following code segment at line 10:
#endregion
B. Insert the following code segment at line 01:
[Conditional("DEBUG")]
C. Insert the following code segment at line 05:
#region DEBUG
Insert the following code segment at line 07:
#endregion
D. Insert the following code segment at line 10:
[Conditional("DEBUG")]
E. Insert the following code segment at line 01:
#if DEBUG
Insert the following code segment at line 10:
#endif
F. Insert the following code segment at line 10:
[Conditional("RELEASE")]
G. Insert the following code segment at line 05:
#if DEBUG
Insert the following code segment at line 07:
#endif
Answer: D,G
Reference: http://stackoverflow.com/questions/2104099/c-sharp-if-then-directives-for-debug-vs-release
Q7. - (Topic 2)
You are developing an application that includes a method named SendMessage.
You need to ensure that the SendMessage() method is called with the required parameters.
Which two code segments can you use to achieve this goal? (Each correct answer presents a complete solution. Choose two.)
A. Option A
B. Option B
C. Option C
D. Option D
Answer: C,D
Explanation: D: ExpandoObject Represents an object whose members can be dynamically added and removed at run time. / The ExpandoObject class enables you to add and delete members of its instances at run time and also to set and get values of these members. This class supports dynamic binding, which enables you to use standard syntax like sampleObject.sampleMember instead of more complex syntax like sampleObject.GetAttribute("sampleMember"). / You can pass instances of the ExpandoObject class as parameters. Note that these instances are treated as dynamic objects in C# and late-bound objects in Visual Basic. This means that you do not have IntelliSense for object members and you do not receive compiler errors when you call non-existent members. If you call a member that does not exist, an exception occurs.
Note:
* Visual C# 2010 introduces a new type, dynamic. The type is a static type, but an object of type dynamic bypasses static type checking. In most cases, it functions like it has type object. At compile time, an element that is typed as dynamic is assumed to support any operation. Therefore, you do not have to be concerned about whether the object gets its value from a COM API, from a dynamic language such as IronPython, from the HTML Document Object Model (DOM), from reflection, or from somewhere else in the program. However, if the code is not valid, errors are caught at run time.
Q8. HOTSPOT - (Topic 2)
You are building a data access layer in an application that contains the following code:
For each of the following statements, select Yes if the statement is true. Otherwise, select No.
Answer:
Q9. - (Topic 1)
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.
Which code should you insert at line 03?
A. DataContractSerializer serializer = new DataContractSerializer();
B. var serializer = new DataContractSerializer();
C. XmlSerlalizer serializer = new XmlSerlalizer();
D. var serializer = new JavaScriptSerializer();
Answer: D
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.
Q10. - (Topic 1)
You are developing an application by using C#. The application includes the following code segment. (Line numbers are included for reference only.)
The DoWork() method must not throw any exceptions when converting the obj object to the IDataContainer interface or when accessing the Data property.
You need to meet the requirements. Which code segment should you insert at line 07?
A. var dataContainer = (IDataContainer)obj;
B. dynamic dataContainer = obj;
C. var dataContainer = obj is IDataContainer;
D. var dataContainer = obj as IDataContainer;
Answer: D
Explanation:
As - The as operator is like a cast operation. However, if the conversion isn't possible, as returns null instead of raising an exception. http://msdn.microsoft.com/en-us/library/cscsdfbt(v=vs.110).aspx