Ensurepass

QUESTION 31

Which class should you use to manage multiple tables and relationships among them?

 

A.       DataRow

B.       DataView

C.        DataTable

D.       DataSet

 

Correct Answer: D

 

 

QUESTION 32

You want to set up a primary key on a column. Which properties on the data column must be set? (Each correct answer presents part of a complete solution. Choose three.)

 

A.       MappingType

B.       AutoIncrementSeed

C.        AutoIncrementStep

D.       AutoIncrement

 < /font>

Correct Answer: BCD

 

 

QUESTION 33

If you want to assign a Car object to a column called CarObject, which attribute must be on the Car class to enable saving the data table to a file?

 

A.       Bindable

B.       DataObject

C.        Serializable

D.       FileIOPermission

 

Correct Answer: C

 

 

QUESTION 34

You are storing custom Car objects in a data table that will be serialized to a file. After serializing to a binary file called cars.bin, you open the file with a binary editor and notice that XML is in the file. Which setting can you use to ensure that you will create a binary file without embedded XML?

 

A.       Set the BatchUpdate setting to SerializationFormat.Binary.

B.       Set the RemotingFormat property to SerializationFormat.Binary.

C.        < /span>Set the DefaultView property to SerializationFormat.Binary.

D.       Set the Constraints property to SerializationFormat.Binary.

 

Correct Answer: B

 

 

QUESTION 35

Which code segment will properly return the TimeSpan returned by the stopWatch variable?

 

A.       Stopwatch stopWatch = new Stopwatch();

stopWatch.Start();

DoSomething();

stopWatch.Stop();

TimeSpan ts = stopWatch.Elapsed;

string elapsedTime = String.Format(“{0:00}:{1:00}:{2:00}.{3:00}”, ts.Hours, ts.Minutes, ts.Seconds, ts. Milliseconds / 10); Console.WriteLine(elapsedTime, “RunTime”);

private void DoSomething()

{ … }

 

B.       Stopwatch stopWatch = new Stopwatch();

stopWatch.Start();

DoSomething();

stopWatch.Reset();

TimeSpan ts = stopWatch.Elapsed;

string elapsedTime = String.Format(“{0:00}:{1:00}:{2:00}.{3:00}”, ts.Hours, ts.Minutes, ts.Seconds, ts. Milliseconds / 10); Console.WriteLine(elapsedTime, “RunTime”);

private void DoSomething()

{ … }

 

C.        Stopwatch stopWatch = new Stopwatch();

stopWatch.Start();

DoSomething();

TimeSpan ts = stopWatch.Elapsed;

string elapsedTime = String.Format(“{0:00}:{1:00}:{2:00}.{3:00}”, ts.Hours, ts.Minutes, ts.Seconds, ts. Milliseconds / 10); Console.WriteLine(elapsedTime, “RunTime”);

private void DoSomething()

{ … }

 

D.       Stopwatch stopWatch = new Stopwatch();

stopWatch.Begin();

DoSomething();

stopWatch.End();

TimeSpan ts = stopWatch.Elapsed;

string elapsedTime = String.Format(“{0:00}:{1:00}:{2:00}.{3:00}”, ts.Hours, ts.Minutes, ts.Seconds, ts. Milliseconds / 10); Console.WriteLine(elapsedTime, “RunTime”);

private void DoSomething()

{ … }

 

Correct Answer: A

 

 

QUESTION 36

You are a tasked with performing a code review. The business rule is the following:

 

Ÿ   If INSERTs into the first table succeed, then INSERT into the second table.

Ÿ   However, if the INSERTs into the second table fail, roll back the inserts in the second table but do not roll back the inserts i
n the first table.

Ÿ   Although this can also be done by way of regular transactions, It needs to be performed using TransactionScope objects.

 

Which code would fit this business rule?

 

A.       try

{

using (TransactionScope scope1 = new TransactionScope(TransactionScopeOption) {

….

try

{

…..

using (TransactionScope scope2 = new TransactionScope(TransactionScopeOption)) { …. }

}

}

}

 

B.       try

{

using (TransactionScope scope1 = new TransactionScope(TransactionScopeOption.Required)) {

using (TransactionScope scope2 = new TransactionScope(TransactionScopeOption.RequiresNew)) { …. }

……

}

}

 

 

C.        try

{

using (TransactionScope scope1 = new TransactionScope(TransactionScopeOption.Required)) {

}

using (TransactionScope scope2 = new TransactionScope(TransactionScopeOption.RequiresNew)) {

….

}

}

 

D.       try

{

using (TransactionScope scope1 = new TransactionScope(TransactionScopeOption.Required)) {

….

try

{

…..

using (TransactionScope scope2 = new TransactionScope(TransactionScopeOption.RequiresNew)) { …. }

}

}

}

 

Correct Answer: D

 

 

QUESTION 37

Which method will return all nodes of an XDocument?

 

A.       doc.DescendantNodes();

B.       doc.Descendants();

C.        doc.Root.Allnodes();

D.       doc.GetAllnodes();

 

Correct Answer: A

 

 

QUESTION 38

Which one of these samples it the correct way to close the connection using Command Behavior?

 

A.       SqlDataReader rdr = new SqlDataReader();

string sql = @”sql statement”;

SqlConnection conn = connection.GetConnection();

SqlCommand cmd = new SqlCommand(sql, conn);

SqlDataReader rdr = cmd.ExecuteReader(CommandBehavior.CloseConnection); Console.WriteLine(“{0}”, rdr);

 

B.       SqlDataReader rdr = new SqlDataReader();

string sql = @”sql statement”;

SqlConnection conn = connection.GetConnection();

SqlCommand cmd = new SqlCommand(sql, conn);

SqlDataReader rdr = cmd.ExecuteReader(CommandBehavior.CloseConnection); rdr.Close();

Console.WriteLine(“{0}”, rdr);

 

C.        SqlDataReader rdr = new SqlDataReader();

string sql = @”sql statement”;

SqlConnection conn = connection.GetConnection();

SqlCommand cmd = new SqlCommand(sql, conn);

SqlDataReader rdr = cmd.ExecuteReader(CommandBehavior.CloseConnection); conn.Close();

Console.WriteLine(“{0}”, rdr);

 

D.       using (SqlDataReader rdr = new SqlDataReader())

{

string sql = @”sql statement”;

SqlConnection conn = connection.GetConnection();

SqlCommand cmd = new SqlCommand(sql, conn);

SqlDataReader rdr = cmd.ExecuteReader(CommandBehavior.CloseConnection); Console.WriteLine(“{0}”, rdr);

}

 

Correct Answer: B

 

 

QUESTION 39

You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4.0 to create an application. The application connects to a Microsoft SQL Server 2008 database. The database includes a database table named ProductCatalog as shown in the exhibit:

 

clip_image001

 

You add the following code segment to query the first row of the ProductCatalog table. (Line numbers are included for reference only.)

 

01 using(SqlConnection cnx = new SqlConnection(connString)

02 {

03 var command = cnx.CreateCommand();

04 command.CommandType = Comma
ndType.Text;

05 command.CommandText = “SELECT TOP 1 * FROM dbo.ProductCatalog”; 06 cnx.Open

();

07 var reader = command.ExecuteReader();

08 if (reader.Read())

09 {

10 var id = reader.GetInt32(0);

11 …

12 reader.Close();

13 }

14 }

 

Which answer belongs in line 11?

 

A.       var weight = reader.GetDouble(1);

var price = reader.GetDecimal(2);

var status = reader.GetBoolean(3);

 

B.       var weight = reader.GetFloat(1);

var price = reader.GetDecimal(2);

var status = reader.GetByte(3);

 

C.        var weight = reader.GetDouble(1);

var price = reader.GetFloat(2);

var status = reader.GetBoolean(3);

 

D.       var weight = reader.GetFloat(1);

var price = reader.Doublel(2);

var status = reader.GetByte(3);

 

Correct Answer: A

 

 

QUESTION 40

You have been assigned the task of writing code that executes an Entity SQL query that returns entity type objects that contain a property of a complex type. (Line numbers are included for reference only.)

 

01 using (EntityCommand cmd = conn.CreateCommand())

02 {

03 cmd.CommandText = esqlQuery;

04 EntityParameter param = new EntityParameter();

05 param.ParameterName = “id”;

06 param.Value = 3;

07 cmd.Parameters.Add(param);

08 using (EntityDataReader rdr = cmd.ExecuteReader(CommandBehavior.SequentialAccess))

09 {

10 while (rdr.Read())

11 {

12 …

13 Console.WriteLine(“Email and Phone Info:”);

14 for (int i = 0; i < nestedRecord.FieldCount; i++)

15 {

16 Console.WriteLine(” ” + nestedRecord.GetName(i) + “: ” + nestedRecord.GetValue(i));

17 }

18 }

19 }

20 }

 

Which code segment should you insert at line 12?

 

A.       DbDataRecord nestedRecord = rdr[“EmailPhoneComplexProperty”] as DbDataRecord;

B.       DbDataRecord nestedRecord = rdr[“EmailPhoneComplexProperty”]

C.        DataSet nestedRecord = rdr[“EmailPhoneComplexProperty”] as ComplexDataSet

D.       ComplexDataRecord nestedRecord = rdr[“EmailPhoneComplexProperty”]

 

Correct Answer: A

 

Instant Access to Download Testing Software & PDF File for Microsoft 70-516 Real Exam

Instant Access to Try Microsoft 70-516 Free Demo

Comments are closed.