Q1. - (Topic 1)
You are debugging an application that calculates loan interest. The application includes the following code. (Line numbers are included for reference only.)
You need to ensure that the debugger breaks execution within the CalculateInterest() method when the loanAmount variable is less than or equal to zero in all builds of the application.
What should you do?
A. Insert the following code segment at line 03: Trace.Assert(loanAmount > 0);
B. Insert the following code segment at line 03: Debug.Assert(loanAmount > 0);
C. Insert the following code segment at line 05: Debug.Write(loanAmount > 0);
D. Insert the following code segment at line 05: Trace.Write(loanAmount > 0);
Answer: A
Explanation:
By default, the Debug.Assert method works only in debug builds. Use the Trace.Assert method if you want to do assertions in release builds. For more information, see Assertions in Managed Code. http://msdn.microsoft.com/en-us/library/kssw4w7z.aspx
Q2. - (Topic 2)
You need to store the values in a collection.
The solution must meet the following requirements:
. The values must be stored in the order that they were added to the collection. . The values must be accessed in a first-in, first-out order.
Which type of collection should you use?
A. SortedList
B. Queue
C. ArrayList
D. Hashtable
Answer: B
Q3. DRAG DROP - (Topic 1)
You are developing an application by using C#. The application will process several objects per second.
You need to create a performance counter to analyze the object processing.
Which three actions should you perform in sequence? (To answer, move the appropriate actions from the list of actions to the answer area and arrange them in the correct order.)
Answer:
Q4. - (Topic 2)
You have the following code:
You need to retrieve all of the numbers from the items variable that are greater than 80. Which code should you use?
A. Option A
B. Option B
C. Option C
D. Option D
Answer: B
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" };
IEnumerable<string> query = fruits.Where(fruit => fruit.Length < 6);
foreach (string fruit in query)
{
Console.WriteLine(fruit);
}
/*
This code produces the following output:
apple
mango
grape */
Q5. - (Topic 2)
You are developing an application that will manage customer records. The application includes a method named FindCustomer.
Users must be able to locate customer records by using the customer identifier or customer name.
You need to implement the FindCustomer() method to meet the requirement.
Which two sets of method signatures 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: B,D
Q6. - (Topic 1)
You are developing an application that will transmit large amounts of data between a client computer and a server. You need to ensure the validity of the data by using a cryptographic hashing algorithm. Which algorithm should you use?
A. RSA
B. Aes
C. HMACSHA256
D. DES
Answer: C
Q7. HOTSPOT - (Topic 1)
You are reviewing the following code:
For each of the following statements, select Yes if the statement is true. Otherwise, select No.
Answer:
Q8. DRAG DROP - (Topic 2)
You are developing a C# console application that outputs information to the screen. The following code segments implement the two classes responsible for making calls to the Console object:
When the application is run, the console output must be the following text:
Log started Base: Log continuing Finished
You need to ensure that the application outputs the correct text.
Which four lines of code should you use in sequence? (To answer, move the appropriate classes from the list of classes to the answer area and arrange them in the correct order.)
Answer:
Q9. - (Topic 2)
You have the following code: You need to retrieve all of the numbers from the items variable that are greater than 80. Which code should you use?
A. Option A
B. Option B
C. Option C
D. Option D
Answer: A
Q10. - (Topic 2)
You need to create a method that can be called by using a varying number of parameters.
What should you use?
A. Method overloading
B. Interface
C. Named parameters
D. Lambda expressions
Answer: A
Explanation:
Member overloading means creating two or more members 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.
Q11. - (Topic 2)
You are developing an application.
The application contains the following code:
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?
A. Catch the ArgumentException exception instead of the ArgumentNullException exception.
B. Throw a new exception in the second catch block.
C. Catch the ArgumentNullException exception first.
D. Re-throw the exception caught by the second catch block.
Answer: A
Q12. DRAG DROP - (Topic 2)
You are developing an application that will write data to a file. The application includes the following code segment. (Line numbers are included for reference only.)
You need to ensure that the WriteData() method will write data to a file.
Which four code segments should you insert in sequence at line 03? (To answer, move the appropriate code segments from the list of code segments to the answer area and arrange them in the correct order.)
Answer:
Q13. - (Topic 1)
You are creating a console application by using C#.
You need to access the application assembly.
Which code segment should you use?
A. Assembly.GetAssembly(this);
B. this.GetType();
C. Assembly.Load();
D. Assembly.GetExecutingAssembly();
Answer: D
Explanation:
Assembly.GetExecutingAssembly - Gets the assembly that contains the code that is currently executing. http://msdn.microsoft.com/en-us/library/system.reflection.assembly.getexecutingassembly(v=vs.110).aspx
Assembly.GetAssembly - Gets the currently loaded assembly in which the specified class is defined. http://msdn.microsoft.com/en-us/library/system.reflection.assembly.getassembly.aspx
Q14. - (Topic 2)
You have the following code (line numbers are included for reference only):
You need to ensure that if an exception occurs, the exception will be logged. Which code should you insert at line 28?
A. Option A
B. Option B
C. Option C
D. Option D
Answer: C
Explanation: * XmlWriterTraceListener
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
)
Q15. - (Topic 2)
You have the following code:
You need to retrieve all of the numbers from the items variable that are greater than 80. Which code should you use?
A. Option A
B. Option B
C. Option C
D. Option D
Answer: A