Web Developer Framework 4.0 Sample Questions – 23

Question: You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4 to create an application. The application connects to a Microsoft SQL Server 2008 database. The database includes a table named dbo.Documents that contains a column with large binary data. You are creating the Data Access Layer (DAL). You add the following code segment to query the dbo.Documents table. (Line numbers are included for reference only.)
01 public void LoadDocuments(DbConnection cnx)
02 {
03 var cmd = cnx.CreateCommand();
04 cmd.CommandText = “SELECT * FROM dbo.Documents”;
05
06 cnx.Open();
07
08 ReadDocument(reader);
09 }
You need to ensure that data can be read as a stream. Which code segment should you insert at line 07

  1. var reader = cmd.ExecuteReader(CommandBehavior.Default);
  2. var reader = cmd.ExecuteReader(CommandBehavior.SchemaOnly);
  3. var reader = cmd.ExecuteReader(CommandBehavior.KeyInfo);
  4. var reader = cmd.ExecuteReader(CommandBehavior.SequentialAccess);

Correct Answer: 4


Question: You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4 to create an application. The application connects to a Microsoft SQL Server 2008 database. The database includes a table named dbo.Documents that contains a column with large binary data. You are creating the Data Access Layer (DAL). You add the following code segment to query the dbo.Documents table. (Line numbers are included for reference only.)
01 Public Sub LoadDocuments(cnx As DbConnection)
02 Dim cmd As var = cnx.CreateCommand()
03 cmd.CommandText = “SELECT * FROM dbo.Documents”
04 …
05 cnx.Open()
06
07 ReadDocument(reader)
08 End Sub
You need to ensure that data can be read as a stream. Which code segment should you insert at line 06

  1. Dim reader As var = cmd.ExecuteReader(CommandBehavior.[Default])
  2. Dim reader As var = cmd.ExecuteReader(CommandBehavior.SchemaOnly)
  3. Dim reader As var = cmd.ExecuteReader(CommandBehavior.KeyInfo)
  4. Dim reader As var = cmd.ExecuteReader(CommandBehavior.SequentialAccess)

Correct Answer: 4


Question: You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4 to create an application. The application connects to a Microsoft SQL Server 2008 database. The database includes a database table named Product Catalog as shown in the exhibit. (Click the Exhibit button.) You add the following code segment to query the first row of the ProductCatalog table. (Line numbers are included for reference only.)
01 using (var cnx = new SqlConnection(connString))
02 {
03 var command = cnx.CreateCommand();
04 command.CommandType = CommandType.Text;
05 command.CommandText =”SELECT TOP 1 * FROM dbo.ProductCatalog”;
06 cnx.Open();
07 var reader = command.ExecuteReader();
08 if (reader.Read()) {
09 var id = reader.GetInt32(0);
10
11 reader.Close();
12 }
13 }
You need to read the values for the Weight, Price, and Status columns. Which code segment should you insert at line 10

  1. var weight = reader.GetDouble(1);
    var price = reader.GetDecimal(2);
    var status = reader.GetBoolean(3);
  2. var weight = reader.GetDecimal(1);
    var price = reader.GetFloat(2);
    var status = reader.GetByte(3);
  3. var weight = reader.GetDouble(1);
    var price = reader.GetFloat(2);
    var status = reader.GetBoolean(3);
  4. var weight = reader.GetFloat(1);
    var price = reader.GetDouble(2);
    var status = reader.GetByte(3);

Correct Answer: 1


Question: You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4 to create an application. The application connects to a Microsoft SQL Server 2008 database. The database includes a database table named Product Catalog as shown in the exhibit. (Click the Exhibit button.) You add the following code segment to query the first row of the Product Catalog table. (Line numbers are included for reference only.)
01 Using cnx As var = New SqlConnection(connString)
02 Dim command As var = cnx.CreateCommand()
03 command.CommandType = CommandType.Text
04 command.CommandText = “SELECT TOP 1 * FROM dbo.ProductCatalog”
05 cnx.Open()
06 Dim reader As var = command.ExecuteReader()
07 If reader.Read() Then
08 Dim id As var = reader.GetInt32(0)
09
10 reader.Close()
11 End If
12 End Using
You need to read the values for the Weight, Price, and Status columns. Which code segment should you insert at line 09

  1. Dim weight As var = reader.GetDouble(1)
    Dim price As var = reader.GetDecimal(2)
    Dim status As var = reader.GetBoolean(3)
  2. Dim weight As var = reader.GetDecimal(1)
    Dim price As var = reader.GetFloat(2)
    Dim status As var = reader.GetByte(3)
  3. Dim weight As var = reader.GetDouble(1)
    Dim price As var = reader.GetFloat(2)
    Dim status As var = reader.GetBoolean(3)
  4. Dim weight As var = reader.GetFloat(1)
    Dim price As var = reader.GetDouble(2)
    Dim status As var = reader.GetByte(3)

Correct Answer: 1


Question: A Windows Communication Foundation (WCF) service has a callback contract. You are developing a client application that will call this service. You must ensure that the client application can interact with the WCF service. What should you do

  1. On the OperationContractAttribute, set the AsyncPattern property value to true.
  2. On the OperationContractAttribute, set the ReplyAction property value to the endpoint address of the client.
  3. On the client, create a proxy derived from DuplexClientBase<TChannel>.
  4. On the client, use GetCallbackChannel<T>.

Correct Answer: 3

Tagged . Bookmark the permalink.

Leave a Reply