Q1. - (Topic 2)
You have the following code. (Line numbers are included for reference only.)
When you execute the code, you get an exception.
You need to ensure that B_Products contain all of the products that start with the letter “B”. What should you do?
A. Option A
B. Option B
C. Option C
D. Option D
Answer: D
Explanation: Simply select the product items.
Q2. DRAG DROP - (Topic 1)
You are developing an application by using C#. The application will output the text string "First Line" followed by the text string "Second Line".
You need to ensure that an empty line separates the text strings.
Which four code segments should you use in sequence? (To answer, move the appropriate code segments to the answer area and arrange them in the correct order.)
Answer:
Q3. - (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
)
Q4. - (Topic 2)
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:
You need to ensure that the unit test will pass. What should you do?
A. Option A
B. Option B
C. Option C
D. Option D
Answer: B
Q5. - (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
Q6. - (Topic 2)
You need to create a method that can be called by using a varying number of parameters.
What should you use?
A. derived classes
B. interface
C. enumeration
D. method overloading
Answer: D
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.