Tuesday, November 18, 2008

MCTS 70-536 Question Bank

UESTION 9

You work as an application developer at www.megaposts.net thet has been

hired by a small local private school to develop a class library that will be used in an

application named ManageAttendance for the purpose of managing student

records.

You are responsible for developing this class library.www.megaposts.net that has instructed

you to create a collection in the application to store learners’ results.

The school has informed you that they currently only have seven learners, but that

this value will triple in the following year. Due to the limited resources, you need to

ensure that the collection you create consumes a minimum amount of resources.

What should you use to create the collection?

A. The HybridDictionary collection class.

B. The HashTable collection class.

C. The ListDictionary collection class.

D. The StringCollection collection class.

.

.

.

Answer: A

Explanation: You should use the HybridDictionary class to create the collection

because this class is useful in scenarios where the number of elements is unknown or

could grow in size. A collection of the HybridDictionary type manages the collection

depending on the number of elements. The HybridDictionary type collection uses

the ListDictionary class to manage the collection when there are only a few

elements. When the number of elements exceeds ten, the HybridDictionary type

collection automatically converts the elements into HashTable management.

Incorrect Answers:

B: You should not use this collection class because this class is used if the total number

of elements to be stored in a collection is known and is greater than ten elements in

length.

C: You should not use this collection class because this class is used if the total number

of elements to be stored in a collection is known and is less than ten elements in length.

D: You should not use this collection class because this class is used to manage a

collection of string values.

QUESTION 10

You work as an application developer at www.megaposts.net that wants you to

develop an application that stores and retrieves client information by means of a

unique account number.

You create a custom collection class, which implements the IDictionary interface,

named ClientDictionary. The following code have been included into the new

application.

//Create Client objects

Client c1 = new Client (”AReid”, “Andy Reid”, Status.Current);

Client c2 = new Client (”DAustin”, “Dean Austin”, Status.New);

//Create ClientDictionary object

IDictionary cData = new ClientDictionary ();

cData.Add (”10001″, c1);

cData.Add (”10002″, c2);

You use the same method to add other Client objects to the collection. You need to

ensure that you are able to retrieve client information associated with the account

number 10111.

What should you do?

A. Use the following code:

Client foundClient;

foundClient = (Client) cData.Find (”10111″);

B. Use the following code:

Client foundClient;

if (cData.Contains (”10111″))

foundClient = cData ["10111"];

C. Use the following code:

Client foundClient;

if (cData.Contains (”10111″))

foundClient = (Client) cData ["10111"];

D. Use the following code:

Client foundClient;

foreach (string key in cData.Keys

{

if (key == “10111″)

foundClient = (Client) cData.Values ["10111"];

}

.

.

.

Answer: C

Explanation: This code invokes the Contains method of the IDictionary interface to

determine whether a value is associated with the key 10111. If a value exists for that

key, then the clientData ["10111"] statement retrieves the client data as a generic

object. The code casts the generic object into a Client object, and it is stored in the

foundClient variable

Incorrect Answers:

A: You should not use the code that uses the Find method because no such method exists

in the IDictionary interface.

B: You should not use the code that assigns the foundClient variable to a generic

object because the foundClient variable is declared as a Client type.

D: You should not use the code that iterates through the Keys collection because it is

unnecessary and process-intensive.

QUESTION 11

You work as an application developer at www.megaposts.net that has

instructed you to create a class named MetricFormula. This class will be used to

compare MetricUnit and EnglishUnit objects.

The MetricFormula is currently defined as follows (Line numbers are used for

reference purposes only):

1. public class MetricFormula

2. {

3.

4. }

You need to ensure that the MetricFormula class can be used to compare the

required objects.

What should you do? (Choose two)

A. Add the following code on line 1:

: IComparable

{

B. Add the following code on line 1:

: IComparer

{

C. Add the following code on line 3:

public int Compare (object x, object y)

{

// implementation code

}

D. Add the following code on line 3:

public int CompareTo (object obj)

{

// implementation code

}

.

.

.

Answer: B, C

Explanation: You should add the code so that it reads as follows:

1. public class MetricFormula : IComparer

2. {

3. public int Compare (object x, object y)

4. {

5. // implementation code

5. }

6. }

You have to implement the IComparer interface to create a comparer class for MetricUnit

and EnglishUnit objects. The IComparer interface provides only one method named

Compare. The Compare method takes two objects and returns an integer value

representing whether those objects are equal, greater than, or less than the other. If the

return value is negative, then the first object is less than the second. The objects are equal

if the return value is zero. The first object is greater than the first if the return value is

positive. The IComparer interface is typically used if you want to implement comparison

across objects of different classes without having to provide implementation in each

comparable class.

Incorrect Answers:

A, D: You should use these two options because this should be implemented by the

MetricUnit and EnglishUnit classes.



Refrence :MCTS 70-536 Question Bank

No comments: