Web Developer Framework 4.0 Sample Questions – 22

Question: A Windows Communication Foundation (WCF) application uses a data contract that has several data members. You need the application to throw a SerializationException if any of the data members are not present when a serialized instance of the data contract is deserialized.What should you do

  1. Add the KnownType attribute to the data contract. Set a default value in each of the data member declarations.
  2. Add the KnownType attribute to the data contract. Set the Order property of each data member to unique integer value.
  3. Set the EmitDefaultValue property of each data member to false.
  4. Set the IsRequired property of each data member to true.

Correct Answer: 4


Question: You might need to use the scroll bar to view the entire contents of the question. Question You are creating a Windows Communication Foundation (WCF) service that implements operations in a RESTful manner. You need to add a delete operation.You implement the delete method as follows.
void DeleteItems(string id);
You need to configure WCF to call this method when the client calls the service with the HTTP DELETE operation.What should you do

  1. Add the WebInvoke(UriTemplate = “/Items/{id}”, Method=”DELETE”) attribute to the operation.
  2. Add the HttpDelete attribute to the operation.
  3. Replace the string parameter with a RemovedActivityAction parameter.
  4. Replace the return type with RemovedActivityAction.

Correct Answer: 1


Question: You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4 to create an application.
You are creating the data layer of the application.
You write the following code segment. (Line numbers are included for reference only.)
01public static SqlDataReader GetDataReader(string sql){
02SqlDataReader dr = null;
03
04return dr;
05}
You need to ensure that the following requirements are met:
The SqlDataReader returned by the GetDataReader method can be used to retrieve rows from the database. SQL connections opened within the GetDataReader method will close when the
SqlDataReader is closed.
Which code segment should you insert at line 03

  1. using (SqlConnection cnn = new SqlConnection(strCnn)) {
    try {
    SqlCommand cmd = new SqlCommand(sql, cnn);
    cnn.Open();
    dr = cmd.ExecuteReader();
    }
    catch {
    throw;
    }
    }
  2. SqlConnection cnn = new SqlConnection(strCnn);
    SqlCommand cmd = new SqlCommand(sql, cnn);
    cnn.Open();
    try {
    dr = cmd.ExecuteReader();
    }
    finally {
    cnn.Close();
    }
  3. SqlConnection cnn = new SqlConnection(strCnn);
    SqlCommand cmd = new SqlCommand(sql, cnn);
    cnn.Open();
    try {
    dr = cmd.ExecuteReader();
    cnn.Close();
    }
    catch {
    throw;
    }
  4. SqlConnection cnn = new SqlConnection(strCnn);
    SqlCommand cmd = new SqlCommand(sql, cnn);
    cnn.Open();
    try {
    dr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
    }
    catch {
    cnn.Close();
    throw;
    }

Correct Answer: 4


Question: You create an ASP.NET page that contains the following tag.
<h1 id="hdr1" runat="server">Page Name</h1>
You need to write code that will change the contents of the tag dynamically when the page is loaded.
What are two possible ways to achieve this goal (Each correct answer presents a complete solution.Choose two.)

  1. this.hdr1.InnerHtml = "Text";
  2. (hdr1.Parent as HtmlGenericControl).InnerText = "Text";
  3. HtmlGenericControl h1 = this.FindControl("hdr1") as HtmlGenericControl;
    h1.InnerText = "Text";
  4. HtmlGenericControl h1 = Parent.FindControl("hdr1") as HtmlGenericControl;
    h1.InnerText = "Text";

Correct Answer: 1 & 3


Question: You are building a client for a Windows Communication Foundation (WCF) service. You need to create a proxy to consume this service. Which class should you use

  1. ChannelFactory<TChannel>
  2. ServiceHost
  3. ClientRuntime
  4. CommunicationObject

Correct Answer: 1

Tagged . Bookmark the permalink.

Leave a Reply