Question: You need to select a class that is optimized for key-based item retrieval from both small and large collections. Which class should you choose?
- OrderedDictionary class
- HybridDictionary class
- ListDictionary class
- Hashtable class
Correct Answer: 2
Question: You are developing a custom-collection class. You need to create a method in your class. You need to ensure that the method you create in your class returns a type that is compatible with the Foreach statement. Which criterion should the method meet?
- The method must return a type of either IEnumerator or IEnumerable.
- The method must return a type of IComparable.
- The method must explicitly contain a collection.
- The method must be the only iterator in the class.
Correct Answer: 1
Question: You write the following code.
public delegate void FaxDocs(object sender, FaxArgs args);
You need to create an event that will invoke FaxDocs. Which code segment should you use?
public static event FaxDocs Fax;
public static event Fax FaxDocs;
public class FaxArgs : EventArgs {
private string coverPageInfo;
public FaxArgs(string coverInfo) {
this.coverPageInfo = coverPageInfo;
}
public string CoverPageInformation {
get {return this.coverPageInfo;}
}}public class FaxArgs : EventArgs {
private string coverPageInfo;
public string CoverPageInformation {
get {return this.coverPageInfo;}
}}
Correct Answer: 1
Question: You are writing a custom dictionary. The custom-dictionary class is named MyDictionary. You need to ensure that the dictionary is type safe. Which code segment should you use?
class MyDictionary : Dictionary<string, string>
class MyDictionary : HashTable
class MyDictionary : IDictionary
class MyDictionary { ... }
Dictionary<string, string> t = new Dictionary<string, string>();
MyDictionary dictionary = (MyDictionary)t;
Correct Answer: 1
Question: You are developing a custom event handler to automatically print all open documents. The event handler helps specify the number of copies to be printed. You need to develop a custom event arguments class to pass as a parameter to the event handler. Which code segment should you use?
public class PrintingArgs
{
private int copies;
public PrintingArgs(int numberOfCopies)
{
this.copies = numberOfCopies;
}
public int Copies
{
get
{
return this.copies;
}
}
}public class PrintingArgs : EventArgs {
private int copies;
public PrintingArgs(int numberOfCopies) {
this.copies = numberOfCopies;
}
public int Copies {
get { return this.copies; }
}
}public class PrintingArgs {
private EventArgs eventArgs;
public PrintingArgs(EventArgs ea) {
this.eventArgs = ea;
}
public EventArgs Args {
get { return eventArgs; }
}
}public class PrintingArgs : EventArgs {
private int copies;
}
Correct Answer: 2