Q1. You are developing an application that stores data in SQL Server 2005 database. You need to write a query that retrieves all orders in the orders table that were placed on January 1, 2011. You write the following query:
SELECT * FROM Orders
WHERE OrderDate = 01/01/2011
The statement executes without any error but does not return any data. You are certain that the database contains order from this date. How should you correct the SQL statement?
A. SELECT * FROM Orders
WHERE OrderDate = #01/01/2011#
B. SELECT * FROM Orders
WHERE OrderDate = %01/01/2011%
C. SELECT * FROM Orders
WHERE OrderDate = '01/01/2011'
D. SELECT * FROM Orders
WHERE OrderDate = "01/01/2011"
Answer: C
Q2. You are designing a database for your company. You are reviewing the normalization for the database tables.
You review the following Orders table:
Which of the following statement is true for the Orders table?
A. It meets the requirements for the first normal form.
B. It meets the requirements for the second normal form.
C. It meets the requirements for the third normal form.
D. It meets the requirements for the fourth normal form.
Answer: A
Q3. You are developing an application that will be run from the command line. Which of the following methods would you use for getting input from to the command line?
A. File.Read
B. File.Write
C. Console.Read
D. Console.Write
Answer: C
Q4. You are developing a C# application. You create a class of the name Widget. You use some third-party libraries, one of which also contains a class of the name Widget. You need to make sure that using the Widget class in your code causes no ambiguity. Which C# keyword should you use to address this requirement?
A. namespace
B. override
C. delegate
D. class
Answer: A
Q5. You are writing code to handle events in your program. You define a delegate named PolygonHandler like this:
public delegate void PolygonHandler(Polygon p);
You also create a variable of the PolygonHandler type as follows:
PolygonHandler handler;
Later in the program, you need to add a method named CalculateArea to the method invocation list of the handler variable. The signature of the CalculateArea method matches the signature of the PolygonHandler method. Any code that you write should not affect any existing event-handling code. Given this restriction, which of the following code lines should you write?
A. handler = new PolygonHandler(CalculateArea);
B. handler = CalculateArea;
C. handler += CalculateArea;
D. handler -= CalculateArea;
Answer: C
Q6. You need to gain a better understanding of the solution before writing the program. You decide to develop an algorithm that lists all necessary steps to perform an operation in the correct order. Any technique that you use should minimize complexity and ambiguity. Which of the following techniques should you use?
A. flowchart
B. decision table
C. C# program
D. A paragraph in English
Answer: A
Q7. You are C# developer who is developing a Windows application. You write the following code:
Object o;
Later in the code, you need to assign the value in the variable o to an object of Rectangle type. You expect that at runtime the value in the variable o is compatible with the Rectangle class. However, you need to make sure that no exceptions are raised when the value is assigned. Which of the following code should you use?
A. Rectangle r = (Rectangle) o;
B. Rectangle r = o;
C. Rectangle r = o as Rectangle;
D. Rectangle r = o is Rectangle;
Answer: D
Q8. You are developing an application that uses the Stack data structure. You write the following code:
Stack first = new Stack(); first.Push(50); first.Push(45); first.Pop();
first.Push(11);
first.Pop();
first.Push(7);
What are the contents of the stack, from top to bottom, after these statements are executed?
A. 7, 11, 50
B. 7, 45
C. 7, 50
D. 7, 11, 45
Answer: C
Q9. You have written a C# method that opens a database connection by using the SqlConnect object. The method retrieves some information from the database and then closes the connection. You need to make sure that your code fails gracefully when there is a database error. To handle this situation, you wrap the database code in a try-catch-finally block. You use two catch blocks—one to catch the exceptions of type SqlException and the second to catch the exception of type Exception. Which of the following places should be the best choice for closing the SqlConnection object?
A. Inside the try block, before the first catch block
B. Inside the catch block that catches SqlException objects
C. Inside the catch block that catches Exception objects
D. Inside the finally block
Answer: D
Q10. You are developing an application that needs to retrieve a list of customers and their orders from a SQL Server database. After the list is retrieved, you should be able to display this data, even when a connection to the SQL Server is not available. Which of the following classes should you use to hold the data?
A. DataAdapter
B. DataSet
C. DataView
D. SqlDataReader
Answer: B