Exam 70-562 : Microsoft .NET Framework 3.5, ASP.NET Application Development – 14

Question: You work as a Web Developer at Company.com. You are in the process of creating a Web application that uses Microsoft ASP.NET 3.5. The following code exists on a page (The line numbers are included for reference purposes):
01 string connStr = WebConfigurationManager.ConnectionStrings[0].ConnectionString;
02 using (SqlConnection conn = new SqlConnection(connStr))
03 {
04 SqlCommand cmd = new SqlCommand(“GetMenuItems”, conn);
05 cmd.CommandType = CommandType.StoredProcedure;
06 conn.Open();
07
08 }
The GetMenuItems stored procedure returns XML the following format:

<MenuItems>
<MenuItem ID="Item1" Text="Item 1" Image="Item1.gif" NavigateUrl="Item1.aspx"/>
<MenuItem ID="Item2" Text="Item 2" Image="Item2.gif" NavigateUrl="Item2.aspx"/>
</MenuItems> 

You have to insert the string Panel into the ID feature of every MenuItem element programmatically. Identify the code segment should you insert at line 07?

  1. You should consider inserting:
    SqlDataAdapter adapter = new SqlDataAdapter(cmd, conn);
    DataSet ds = new DataSet();
    adapter.Fill(ds);
    ds.Tables[0].Select(“//@ID”).SetValue(“Panel{0}”, 0);
  2. You should consider inserting:
    XmlDocument doc = new XmlDocument();
    using (XmlReader reader = cmd.ExecuteXmlReader())
    {
    doc.Load(reader);
    }
    foreach (XmlNode node in doc.SelectNodes(“//@ID”))
    {
    node.Value = node.Value.Insert(0, “Panel”);
    }
  3. You should consider inserting:
    SqlDataAdapter adapter = new SqlDataAdapter(cmd, conn);
    DataSet ds = new DataSet();
    adapter.Fill(ds);
    XmlDataDocument doc = new XmlDataDocument(ds);
    using (XmlReader reader = cmd.ExecuteXmlReader())
    {
    doc.Load(reader);
    }
    foreach (XmlNode node in doc.SelectNodes(“//@ID”))
    {
    node.Value = node.Value.Insert(0, “Panel”);
    }
  4. You should consider inserting:
    SqlDataAdapter adapter = new SqlDataAdapter(cmd, conn);
    DataSet ds = new DataSet();
    adapter.Fill(ds);
    ds.Tables[0].Select().SetValue(“//@ID=Panel{0}”, 0);

Correct Answer: 2


Question: You work as a Web Developer at Company.com. You are in the process of creating a Web application that uses Microsoft ASP.NET 3.5. The Web application will be used to displays sales data from an XML file. The XML file does not contain an inline schema. You notice that a DataSet-compatible schema is stored in an XSD file. The schema identifies a subset of the nodes that exist in the XML file. You should not make any modifications to this schema. You decide to load the XML information in order for it to be navigated relationally and with the XML Document Object Model (DOM). What should you do?

  1. You should consider loading the XML file into a DataSet instance. Thereafter an XmlDataDocument instance should be created from the DataSet instance.
  2. You should consider loading the XSD file into a DataSet instance. Then the XML file should be loaded into the DataSet instance using the InferSchema read mode. Thereafter the XmlDataDocument instance has to be created from the DataSet instance.
  3. You should consider loading the XSD file into a DataSet instance. Then an XmlDataDocument instance should be created from the DataSet instance. Thereafter you need to load the XML file into the XmlDataDocument instance.
  4. You should consider loading the XSD file as well as the XML file into a DataSet instance. Then an XmlDataDocument instance should be created from the DataSet instance. Thereafter you need to load the XML file into the XmlDataDocument instance.

Correct Answer: 3


Question: You work as a Web Application Developer at Company.com. You are in the process of creating an ASP.NET application that uses Microsoft .NET Framework 3.5. The code below is in the application:

Public Class Orders
Public Property oValue() As Decimal
Get
End Get
Set(ByVal value As Decimal)
End Set
End Property
End Class 

The application contains a Web form. A Label control named TestLbl is in the Web form. You decide to make use of a StringReader variable named xmlStream to access the XML fragment below:

<Orders>
<Name>Jimmy Rainer</Name>
<Value>25</Value>
</Orders> 

Management wants you to ensure that the price of the product from the XML fragment is displayed in TestLbl. What should you do?

  1. You should consider using the code segment below:
    Dim _var As New XmlSerializer(GetType(Value))
    Dim placedOrder As Orders = TryCast(_var.Deserialize(xmlStream), Orders)
    TestLbl.Text = placedOrder.oValue.ToString()
  2. You should consider using the code segment below:
    Dim xDoc As New XmlDocument()
    xDoc.Load(xmlStream)
    Dim placedOrder As Orders = xDoc.OfType(Of Orders)().First()
    TestLbl.Text = placedOrder.oValue.ToString()
  3. You should consider using the code segment below:
    Dim xr As XmlReader = XmlReader.Create(xmlStream)
    Dim placedOrder As Orders = _
    TryCast(xr.ReadContentAs(GetType(Orders), Nothing), Orders)
    TestLbl.Text = placedOrder.oValue.ToString()
  4. You should consider using the code segment below:
    Dim dt As New DataTable()
    dt.ExtendedProperties.Add(“Type”, “Orders”)
    dt.ReadXml(xmlStream)
    TestLbl.Text = dt.Rows(0)(“oValue”).ToString()

Correct Answer: 1


Question: You work as the application developer at Company.com. You make use of .NET Framework 3.5 to create an ASP.NET application that has an ASPX page named error.aspx. When an unhangled exception is thrown, you want the exception to be written to the Event log file and the error.aspx page to be displayed. What should you do? (Choose all that apply)

  1. This can be accomplished by adding the code segment below to the Global.asax file:
    void Application_Error(object sender, EventArgs e)
    {
    Exception exc = Server.GetLastError();
    // Write Exception to event log
    }
  2. This can be accomplished by adding the code segment below to the Web.config file:
    <customErrors mode=”Off” defaultRedirect=”error.aspx” />
  3. This can be accomplished by adding the code segment below to the Web.config file:
    <customErrors mode=”On” defaultRedirect=” error.aspx” />
  4. This can be accomplished by adding the code segment below to error.aspx file.
    void Page_Error(object sender, EventArgs e)
    {
    Exception exc = Server.GetLastError();
    // Write details to event log
    Server.ClearError();
    }

Correct Answer: 1,3


Question: You work as a Web Developer at Company.com. You make use of Microsoft ASP.NET 3.5 to create a Web application. You decide to create a DataSet instance named CKdata. You use the following XML data to create CKdata:

<Exams>
<Cisco Code="642-432">
<Cisco Code ="642-664">
<Comptia Code="220-601">
<Suv Code="310-880">
<Microsoft Code="70-562">
<Microsoft Code ="70-431">
</Exams> 

The Code characteristic used in the XML data signifies the exam number for a exam. There is a method named ProcessExamCode that accepts Code as a parameter. It is vital that you create a DataTableReader instance as well as calling the ProcessExamCode method for every exam. Identify the code segment should you use?

  1. You should consider using:
    (DataTableReader reader = CKdata.CreateDataReader())
    {
    do
    {
    ProcessExamCode(reader[“Code”]);
    } while (reader.NextResult());
    }
  2. You should consider using:
    (DataTableReader reader = CKdata.CreateDataReader())
    {
    do
    {
    while (reader.NextResult())
    {
    ProcessExamCode(reader.GetString(0));
    }
    } while (reader.Read());
    }
  3. You should consider using:
    (DataTableReader reader = CKdata.CreateDataReader())
    {
    do
    {
    while (reader.Read())
    {
    ProcessExamCode(reader[“Code”]);
    }
    } while (reader.NextResult());
    }
  4. You should consider using:
    (DataTableReader reader = CKdata.CreateDataReader())
    {
    while (reader.NextResult())
    {
    reader.Read();
    ProcessExamCode(reader.GetString(0));
    }
    }

Correct Answer: 3

Tagged . Bookmark the permalink.

Leave a Reply