Ensurepass

QUESTION 31

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

 

  1. DataRow

  2. DataView

  3. DataTable

  4. 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.)

 

  1. MappingType

  2. AutoIncrementSeed

  3. AutoIncrementStep

  4. AutoIncrement

 

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?

 

  1. Bindable

  2. DataObject

  3. Serializable

  4. 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?

 

  1. Set the BatchUpdate setting to SerializationFormat.Binary.

  2. Set the RemotingFormat property to SerializationFormat.Binary.

  3. Set the DefaultView property to SerializationFormat.Binary.

  4. 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?

 

  1. 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()

{ … }

 

  1. 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()

{ … }

 

  1. 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()

{ … }

 

  1. 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 in 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?

 

  1. try

{

using (TransactionScope scope1 = new TransactionScope(TransactionScopeOption) {

….

try

{

…..

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

}

}

}

 

  1. try

{

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

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

……

}

}

 

 

  1. try

{

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

}

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

….

}

}

 

  1. 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?

 

  1. doc.DescendantNodes();

  2. doc.Descendants();

  3. doc.Root.Allnodes();

  4. doc.GetAllnodes();

 

Correct Answer: A

 

 

QUESTION 38

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

 

  1. 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);

 

  1. 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);

 

  1. 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);

 

  1. 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:

 

70-516-demo-4

 

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 = CommandType.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?

 

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

var price = reader.GetDecimal(2);

var status = reader.GetBoolean(3);

 

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

var price = reader.GetDecimal(2);

var status = reader.GetByte(3);

 

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

var price = reader.GetFloat(2);

var status = reader.GetBoolean(3);

 

  1. 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?

 

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

  2. DbDataRecord nestedRecord = rdr[“EmailPhoneComplexProperty”]

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

  4. ComplexDataRecord nestedRecord = rdr[“EmailPhoneComplexProperty”]

 

Correct Answer: A

 

Instant Access to Download Latest Complete Collection of Microsoft MCTS 70-516 Real Exam

Try Microsoft MCTS 70-516 Free Demo

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.