Thursday, December 24, 2009

70-536

1.You are writing a custom dictionary. The custom-dictionary class is named MyDictionary. You need toensure that the dictionary is type safe. Which code segment should you use?A. class MyDictionary : DictionaryB. class MyDictionary : HashTableC. class MyDictionary : IDictionaryD. class MyDictionary { ... } Dictionary t = new Dictionary(); MyDictionary dictionary = (MyDictionary)t;Answer: A

2.You are creating a class named Age.You need to ensure that the Age class is written such thatcollections of Age objects can be sorted. Which code segment should you use?A. public class Age { public int Value; public object CompareTo(object obj) { if (obj is Age) { Age _age = (Age) obj; return Value.CompareTo(obj); } throw new ArgumentException("object not an Age"); } }B. public class Age { public int Value; public object CompareTo(int iValue) { try { return Value.CompareTo(iValue); } catch { throw new ArgumentException ("object not an Age"); } } }C. public class Age : IComparable { public int Value; public int CompareTo(object obj) { if (obj is Age) { Age _age = (Age) obj; return Value.CompareTo(_age.Value); } throw new ArgumentException("object not an Age"); } }D. public class Age : IComparable { public int Value; public int CompareTo(object obj) { try { return Value.CompareTo(((Age) obj).Value); } catch { return -1; } } }Answer: C

Microsoft > 70-536 self-study training

No comments:

Post a Comment