You work as the application developer at www.megaposts.net. www.megaposts.net uses Visual
Studio.NET 2005 as its application development platform.
You are in the process of storing numerical values up to 2,100,000,000 into a
variable and may require storing negative values using a .NET Framework 2.0
application. You are required to optimize memory usage
What should you do?
A. Int32
B. UInt16
C. UInt32
D. Int16
…
…
…
Answer: A
Explanation: The Int32 type should be used in the scenario as it can be used to store
positive and negative numerical values from -2,147,483,648 to +2,147,483,647.
Incorrect Answers:
B, C: The UINT32 and UInt16 type should not be used in the scenario because they are
used to store only unsigned positive numbers.
D: The Int16 type should not be used as you will only be allowed to store values from
-32768 to +32768.
QUESTION 2
You work as an application developer at Certkiller .com. You are currently in the
process of creating a class that stores data about Certkiller .com’s customers.
Certkiller .com customers are assigned unique identifiers and various characteristics
that may include aliases, shipping instructions, and sales comments. These
characteristics can change in both size and data type.
You start by defining the Customer class as shown below:
public class Customer
{
private int custID;
private ArrayList attributes;
public int CustomerID
{
get {return custID;}
}
public Customer (int CustomerID)
{
this.custID = CustomerID;
this.attributes = new ArrayList ();
}
public void AddAttribute (object att)
{
attributes.Add (att);
}
}
You have to create the FindAttribute method for locating attributes in Customer
objects no matter what the data type is.
You need to ensure that the FindAttribute method returns the attribute if found,
and you also need to ensure type-safety when returning the attribute.
What should you do?
A. Use the following code to declare the FindAttribute method:
public T FindAttribute (T att)
{
//Find attribute and return the value
}
B. Use the following code to declare the FindAttribute method:
public object FindAttribute (object att)
{
//Find attribute and return the value
}
C. Use the following code to declare the FindAttribute method:
public T FindAttribute
{
//Find attribute and return the value
}
D. Use the following code to declare the FindAttribute method:
public string FindAttribute (string att)
{
//Find attribute and return the value
}
…
…
…
Answer: C
Explanation: This code declares the method FindAttribute and specifies an
argument named att using the T placeholder as the argument and return data type.
To ensure the FindAttribute method accepts arguments of different types, you
should specify an argument using a generic placeholder. The argument att in this
generic method will accept any valid data type and ensures type-safety by returning
that same data type.
Incorrect Answers:
A: You should not use this code because it does not declare the placeholder T. when
declaring a generic method, you have to use the < > bracketsto declare the place holder
before using it.
B: You should not use this code because it does not guarantee type-safery.
D: You should not use this code because it will only accept a string argument and
return a string argument.
Refrence: MCTS 70-536 Question Bank
No comments:
Post a Comment