Collection Classes MCQ C#

Errorlogger
0
1. Which among is the ordered collection class?
a) BitArray
b) Queue
c) HashTable
d) Stack

e) both b and d


2. Which among is not an interface declared in System.Collection namespace?
a) IDictionaryComparer
b) IEnumerable
c) IEnumerator
d) Icomparer



3. Which among the following is correct way to find out the number of elements currently present in an ArrayListCollection called arr?
a) arr.Capacity
b) arr.Count
c) arr.MaxIndex
d) arr.UpperBound



4. Which statement is correct about the C#.NET code snippet given below?
  1. Stack st = new Stack();
  2. st.Push("Csharp");
  3. st.Push(7.3);
  4. st.Push(8);
  5. st.Push('b');
  6. st.Push(true);
a) Unsimilar elements like “Csharp”,7.3,8 cannot be stored in the same stack collection.
b) Boolean values can never be stored in Stack collection
c) Perfectly workable code
d) All of the mentioned



5. Which is the correct statement about an ArrayList collection that implements the IEnumerable interface?
a) To access members of ArrayList from the inner class, it is necessary to pass ArrayList class’s reference to it
b) The inner class of ArrayList can access ArrayList class’s members
c) The ArrayList class consist of inner class that implements the IEnumerator interface
d) All of the mentioned



6. Which among is the correct way to access all the elements of the Stack collection created using the C#.NET code snippet given below?
Stack st = new Stack();
st.Push(10);
st.Push(20);
st.Push(-5);
st.Push(30);
st.Push(6);
a) IEnumerable e;
e = st.GetEnumerator();
while (e.MoveNext())
Console.WriteLine(e.Current);
b) IEnumerator e;
e = st.GetEnumerator();
while(e.MoveNext())
Console.WriteLine(e.Current);
c) IEnumerable e;
e = st.GetEnumerable();
while(e.MoveNext())
Console.WriteLine(e.Current);
d) None of the mentioned



7. The correct code to access all the elements of the queue collection created using the C#.NET code snippets given below?
  1. Queue q = new Queue();
  2. q.Enqueue("Harsh");
  3. q.Enqueue('a');
  4. q.Enqueue(false);
  5. q.Enqueue(70);
  6. q.Enqueue(8.5);
a) IEnumerator e;
e = q.GetEnumerator();
while(e.MoveNext())
Console.WriteLine(e.Current);
b) IEnumerable e;
e = q.GetEnumerator();
while(e.MoveNext())
c) IEnumerable e
e = q.GetEnumerable();
while(e.MoveNext())
Console.WriteLine(e.Current);
d) All of the mentioned



8. Which statements among are correct about the Collection Classes available in Framework Class Liberary?
a) Elements of a collection cannot be transmitted over a network
b) Elements stored in a collection can be modified only if all elements are of similar types
c) Elements stored in a Collection can be retrieved but cannot be modified
d) Collection classes make use of efficient algorithms to manage the collection,hence improving performance of the program



9. Among the given collections which is the I/O index based?
a) ArrayList
b) BitArray
c) Stack
d) Queue

e) both a and b


10. Among the given correct statements about the Stack collection?
a) It can be used for evaluation of expressions
b) It is used to maintain a FIFO list
c) All elements in the Stack collection can be accessed using an enumerator
d) Top most element of the Stack collection can be accessed using the Peek()

e) only a, b and d


11. A HashTable t maintains a collection of names of states and capital city of each state.Which among the given to find out whether “New delhi” state is present in the collection or not?
a) t.HasValue(“New delhi”);
b) t.ContainsKey(“New delhi”);
c) t.HasKey(“New delhi”);
d) t.ContainsValue(“New delhi”);



12. In which of the following collections do the I/O based on a key?
a) BitArray
b) SortedList
c) HashTable
d) Stack

e) both b and c


13. The correct about a HashTable collection is?
a) It is a keyed collection
b) It is a ordered collection
c) It is an indexed collection
d) It implements a IDictionaryEnumerator interface in its inner class

e) both a and d
Tags

Post a Comment

0Comments

Post a Comment (0)

#buttons=(Accept !) #days=(30)

Our website uses cookies to enhance your experience. Check Now
Accept !