Q1. You have created a new Web service that provides mapping data. You are working in a Visual Studio environment and use C# as your programming language. You need to test the Web service to ensure that it is returning correct results. What is the easiest way to test your new Web service?
A. Copy and paste the Web service code into ASP.NET Web Applications. Run the Web application to see theresults.
B. Invoke the Web service from an ASP.NET client. Run the Web application to see the results.
C. Run the Web services project from within Visual Studio and use the test page that is displayed in the Webbrowser.
D. Have a large number of beta testers usetheWeb service and check for incorrect results.
Answer: C
Q2. You are creating a new class named Sphere derived from the Shape class. The Shape class has the following code:
class Shape
{
public virtual void Area()
{
// additional code...
}
}
The Area method in the Shape class should provide new functionality but also hide the Shape class implementation of the Area method. Which code segment should you use to accomplish this?
A. class Sphere : Shape
{
public override void Area()
{
// additional code ...
}
}
B. class Sphere : Shape
{
public new void Area()
{
// additional code ...
}
}
C. class Sphere : Shape
{
public virtual void Area()
{
// additional code ...
}
}
D. class Sphere : Shape
{
public static void Area()
{
// additional code ...
}
}
Answer: B
Q3. You are writing a C# program. You write the following method:
public static void TestSwitch(int op1, int op2, char opr)
{
int result;
switch (opr)
{
case '+':
result = op1 + op2;
case '-':
result = op1 - op2;
case '*':
result = op1 * op2;
case '/':
result = op1 / op2;
default:
Console.WriteLine("Unknown Operator");
return;
}
Console.WriteLine("Result: {0}", result);
return;
}
However, when you compile this code, you get the following error message:
Control cannot fall through from one case label to another
How should you modify the code to make sure that it compiles successfully?
A. After each case, add the following code line: break;
B. After each case, add the following code line: continue;
C. After each case, add the following code line: goto default;
D. After each case, add the following code line: return;
Answer: A
Q4. You develop a new ASP.NET inventory application on the Northwind Web server. You deploy the files in the folder c:\WebInventory. The application should be available via the URL www.northwind.com/inventory. The URL www.northwind.com is already set up to point to the Northwind Web server. What should you do to make your inventory application available at the expected URL?
A. Change the name of the directory c:\WebInventory to c:\Inventory.
B. Create a virtual directory named Inventory and point it to c:\WebInventory.
C. Create a virtual directory named WebInventory and point it to c:\Inventory.
D. Move the directory c:\WebInventory to the c:\inetput\wwwroot directory.
Answer: B
Q5. You are developing an algorithm for a retail Web site. You need to calculate discounts on certain items based on the quantity purchased. You develop the following decision table to calculate the discount:
If a customer buys 50 units of an item, what discount will be applicable to the purchase?
A. 5 percent
B. 10 percent
C. 15 percent
D. 20 percent
Answer: C
Q6. You created a class named GeoShape. You defined a method called Area in the GeoShape class. This method calculates the area of a geometric shape. You want the derived classes of GeoShape to supersede this functionality to support the area calculation of additional geometric shapes. When the method Area is invoked on a GeoShape object, the area should be calculated based on the runtime type of the GeoShape object. Which keyword should you use with the definition of the Area method in the GeoShape class?
A. abstract
B. virtual
C. new
D. overrides
Answer: B
Q7. You need to provide printing functionality to several of your classes. Each class’s algorithm for printing will likely be different. Also, not all the classes have an “is-a” relationship with each other. How should you support this functionality?
A. Add the print functionality to a base class with the public access modifier.
B. Have all classes inherit from an abstract base class and override the base-class method to provide their own print functionality.
C. Have all the classes inherit from a base class that provides the print functionality.
D. Create a common interface that all classes implement.
Answer: D
Q8. You need to display specific messages to users when their browser is not running JavaScript. Which of the following code segment should you use?
A. <script runat="server"> ... </script>
B. <script> ... </script>
C. <% ... %>
D. <noscript> ... </noscript>
Answer: D
Q9. You are developing a C# program. You write a recursive method to calculate the factorial of a number. Which of the following code segment should you use to generate correct results?
A. public static int Factorial(int n)
{
if (n == 0)
{
return 1;
}
else
{
return n * Factorial(n - 1);
}
}
B. public static int Factorial(int n)
{
if (n == 0)
{
return 1;
}
else
{
return (n – 1) * Factorial(n);
}
}
C. public static int Factorial(int n)
{
if (n == 0)
{
return n;
}
else
{
return Factorial(n - 1);
}
}
D. public static int Factorial(int n)
{
return n * Factorial(n - 1);
}
Answer: A
Q10. 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