Q1. You are developing a Windows Form with a multiple document interface (MDI). You need to write code that arranges the child windows vertically within the client region of the MDI parent form. Which of the following MdiLayout values should you pass to the LayoutMdi method?
A. MdiLayout.TileVertical
B. MdiLayout.Cascade
C. MdiLayout.TileHorizontal
D. MdiLayout.ArrangeIcons
Answer: A
Q2. You are writing a method named PrintReport that doesn't return a value to the calling code. Which keyword should you use in your method declaration to indicate this fact?
A. void
B. private
C. int
D. string
Answer: A
Q3. 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
Q4. 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
Q5. You are designing a database for your company and are reviewing the normalization for the database tables.
You review the following Customer table: Which of the following statements is true?
A. The Customer table 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 is not normalized.
Answer: D
Q6. You are developing an application that manages customers and their orders. Any solution that you develop must take the least amount of effort but offer the best performance.. Which of the following situations is not a good candidate for implementation with stored procedures in your application?
A. Retrieving the list of all customers in the database
B. Retrieving the list of all orders for particular customers
C. Inserting a new order into the Orders table
D. Ad hoc querying by the database administrator
Answer: D
Q7. Your C# program needs to return the total number of customers in a SQL Server database. The program will be used several times a day. What is the fastest way to return this information from your program? (Select all answers that apply.)
A. Write a SQL query.
B. Write a stored procedure.
C. Use the SqlDataAdapter.Fill method.
D. Use the SqlCommand.ExecuteScalar method.
E. Use the OleDbDataAdapter.Fill method.
Answer: BD
Q8. You are C# developer who is developing a Windows application. You need to provide derived classes the ability to share common functionality with base classes but still define their own unique behavior. Which object oriented programming concept should you use to accomplish this functionality?
A. encapsulation
B. abstraction
C. polymorphism
D. inheritance
Answer: D
Q9. 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
Q10. You are developing a C# program that needs to perform 5 iterations. You write the following code:
01: int count = 0;
02: while (count <= 5)
03: {
04: Console.WriteLine("The value of count = {0}", count);
05: count++;
06: }
When you run the program, you notice that the loop does not iterate five times. What should you do to make sure that the loop is executed exactly five times?
A. Change the code in line 01 to int count = 1;
B. Change the code in line 02 to: while (count == 5)
C. Change the code in line 02 to while (count >= 5)
D. Change the code in line 05 to ++count;
Answer: A
Q11. You are developing a new Windows service application. The application contains three different Windows services. Before these services can be used, they must be installed in the Windows service database. What action should you take to ensure that your services can be installed by a Windows installer tool?
A. Copy the service assembly to the global assembly cache.
B. Add an event log installer to the Windows service project.
C. Inherit the service from a ServiceBase class.
D. Add a service installer to the Windows service project.
Answer: D
Q12. 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
Q13. 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
Q14. You are C# developer who is developing a Windows application. You need to provide a common definition of a base class that can be shared by multiple derived classes. Which keyword should you use to declare the new class?
A. virtual
B. sealed
C. interface
D. abstract
Answer: C
Q15. 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
Q16. You are reviewing a C# program that contains the following class:
public class Rectangle
{
public double Length {get; set;}
public double Width { get; set; }
}
The program executes the following code as part of the Main method:
Rectangle r1, r2;
r1 = new Rectangle { Length = 10.0, Width = 20.0 };
r2 = r1;
r2.Length = 30;
Console.WriteLine(r1.Length);
What will be the output when this code is executed?
A. 10
B. 20
C. 30
D. 40
Answer: C
Q17. You want to display an image on your Web page. This image is stored on a separate Web server but can be accessed with a public URL. Which of the following HTML tags should you use to ensure that the image is displayed when the user navigates to your Web page?
A. <LINK>
B. <IMG>
C. <A>
D. <HTML>
Answer: B
Q18. You are writing code for a business application by using C#. Write the following statement to declare an array:
int[] numbers = { 1, 2, 3, 4, 5, };
Now, you need to access the second item in this array (the number 2). Which of the following expression should you use?
A. numbers[0]
B. numbers[1]
C. numbers[2]
D. numbers[3]
Answer: B