QUESTION 4
You work as the application developer at www.megaposts.net uses Visual
Studio.NET 2005 as its application development platform.
You have recently finished development of a class named TestReward and package
the class in a .NET 2.0 assembly named TestObj.dll. After you ship the assembly
and it is used by client applications, you decide to move the TestReward class from
TestObj.dll assembly to the TestRewardObj.dll Assembly. You are to ensure when
you ship the updated TestObj.dll and TestRewardObj.dll assemblies that the client
applications continue to work and do not require recompiling.
What should you do?
A. The TypeForwardedTo attribute should be used
B. The TypeConvertor.ConvertTo method should be used
C. The InternalsVisibleTo attribute should be used
D. The Type Convertor.ConvertFrom method should be used
…
…
…
Answer: A
Explanation: The statement used for you to add a type from one assembly into
another assembly is the TypeForwardTo attribute which enables you not to have the
application recompiled.
Incorrect Answers:
B, D: The TypeConverter class provides a unified way of converting different types of
values to other types and can not be used to move a type.
C: The method in question here specifies all nonpublic types in an assembly are visible
to other assemblies but can not be used to move types.
QUESTION 5
You work as an application developer at www.megaposts.net. You have recently created a
custom collection class named ShoppingList for a local supermarket. This custom
class will include ShoppinItem objects that have the public properties listed below.
* Name
* AisleNumber
* OnDiscount
You are required to enable users of your class to iterate through the ShoppingList
collection, and to list each product name and aisle number using the foreach
statement.
You need to achieve this by declaring the appropriate code.
What code should you use?
A. public class ShoppingList : ICollection
{
// Class implementation
}
B. public class ShoppingList : IEnumerator, IEnumerable
{
// Class implementation
}
C. public class ShoppingList : Ilist
{
// Class implementation
}
D. public class ShoppingList : Enum
{
// Class implementation
}
Answer: B
Explanation: You should implement the IEnumerable and IEnumerator interfaces
of the System.Collections namespace to ensure that your collection class supports
foreach iteration. The IEnumerable interface defines only one method named
GetEnumerator that returns an object of type IEnumerator of the
System.Collections namespace and is used to support iteration over a collection. The
IEnumerator interface supports methods, such as Current, MoveNext, and Reset to
iterate through a collection. The Current method returns the current element of the
collection. The Move method positions the enumerator to the next available element
of the collection. The Reset method positions the enumerator before the first
element of the collection.
Incorrect Answers:
A: You should not use the code that implements the ICollection interface because this
interface is used to define properties in a collection. Implementing this interface will not
ensure that your collection class supports foreach iteration because it does not inherit the
IEnumerator interface.
C: You should not use the code that implements the Ilist interface because this
interface is used to define properties of a non-generic list of items accessed by index.
Implementing this interface will not ensure that your collection class supports foreach
iteration because it does not inherit the IEnumerator interface.
D: You should not use the code that inherits the Enum because this structure is used
as a base class for those classes that provide enumeration values. Inheriting the Enum
structure will not ensure that your collection class supports foreach iteration.
Reference: MCTS 70-536 Question Bank

No comments:
Post a Comment