Programming MCQs

Top 20 MCQ Questions on C# Collection Classes

Pinterest LinkedIn Tumblr
Here are the collections of MCQ questions on C# collection classes includes the top 20 multiple-choice questions related to the collection classes defined in the System.Collections namespace in C#. It includes objective-type questions of the different properties and methods of collection classes such as ArrayList, Hashtable, SortedList, Stack, Queue, and BitArray.

Read Also: MCQ Questions on C# with Answer

1. State whether the following statements about the collection classes are True or False.
i) Collection provides automatic memory management and capacity expansion.
ii) The System.Collection.Classes namespace provides various classes.
A) i-True, ii-False
B) i-True, ii-True
C) i-False, ii-True
D) i-False, ii-False

2. Which of the following are the most useful collection classes defined in C#.
i) ArrayList
ii) ByteArray
iii) Stack
iv) SortedList
A) i, ii and iii only
B) i, iii and iv only
C) ii, iii and iv only
D) All i, ii, iii and iv

3. … represents the ordered collection of an object that can be indexed individually.
A) ArrayList
B) BitArray
C) Stack
D) SortedList

4. Which of the following are the commonly used properties of the ArrayList class.
i) Capicity
ii) Count
iii) Key
iv) IsReadyOnly
A) i, ii and iii only
B) i, iii and iv only
C) i, ii and iv only
D) All i, ii, iii and iv

5. State whether the following statements about the Hashtable are True or False.
i) Hashtable uses key as well as an index to access the elements in the collection.
ii) Each item in the hash table has a key/value pair.
A) i-True, ii-False
B) i-True, ii-True
C) i-False, ii-True
D) i-False, ii-False

6. Which of the following are the commonly used properties of the SortedList class.
i) Capacity
ii) Count
iii) Item
iv) Length
A) i, ii and iii only
B) i, iii and iv only
C) i, ii and iv only
D) All i, ii, iii and iv

7. … is used when you need last-in, first-out access of items.
A) List
B) Stack
C) Array
D) Queue

8. … are the commonly used properties of the Hashtable class.
i) Count
ii) Item
iii) Values
iv) Keys
A) i, ii and iii only
B) i, iii and iv only
C) i, ii and iv only
D) All i, ii, iii and iv

9. State whether the following statements about SortedList are True or False.
i) SortedList is a combination of an array and a hash table.
ii) It contains a list of items that can be accessed using a key or an index.
A) i-True, ii-False
B) i-True, ii-True
C) i-False, ii-True
D) i-False, ii-False

10. The method … removes and returns the object at the top of the stack.
A) public virtual object delete();
B) public virtual void pop();
C) public virtual object clear();
D) public virtual object pop();

11. … is used when you need a first-in, first-out access of items.
A) Stack
B) List
C) Queue
D) Deque

12. The … property gets or sets the value of the bit at a specific position in the BitArray.
A) Item
B) ItemLength
C) Value
D) SetValue

13. The … property gets or sets the number of elements in the BitArray.
A) Number
B) Length
C) ItemLength
D) SetValue

14. The … property gets and sets the value associated with a specific key in the SortedList.
A) Values
B) KeyValues
C) Keys
D) Item

15. The … property gets or sets the number of elements that the ArrayList can contain.
A) Count
B) Item
C) Capacity
D) Length

16. The … method returns the zero-based index of the first occurance of a value in the ArrayList or in a portion of it.
A) public virtual int IndexOf(object);
B) public virtual int Index(object);
C) public virtual int IntexOf();
D) public virtual int FirstIndex();

17. The … method removes the element with the specified key from the Hashtable.
A) public virtual void Remove();
B) public virtual void Remove(object key);
C) public virtual void Clear(object key);
D) public virtual void Delete(object key);

18. The … method sets the capacity to the actual number of elements in the SortedList.
A) public virtual void Capacity();
B) public virtual void Size();
C) public virtual void TrimToSize();
D) public virtual void SetSize();

19. The … method removes and returns the object at the begining of the Queue.
A) public virtual void Dequeue();
B) public virtual void Delete();
C) public virtual void Clear();
D) public virtual object Dequeue();

20. The … method inverts all the bit values in the current BitArray so that elements set to True are changed to False, and elements set to False are changed to True.
A) public BitArray Not();
B) public BitArray Invert();
C) public BitArray Xor();
D) public BitArray SetInvert();

Answers:

  1. A) i-True, ii-False
  2. B) i, iii and iv only
  3. A) ArrayList
  4. C) i, ii and iv only
  5. C) i-False, ii-True
  6. A) i, ii and iii only
  7. B) Stack
  8. D) All i, ii, iii and iv
  9. B) i-True, ii-True
  10. D) public virtual object pop();
  11. C) Queue
  12. A) Item
  13. B) Length
  14. D) Item
  15. C) Capacity
  16. A) public virtual int IndexOf(object);
  17. B) public virtual void Remove(object key);
  18. C) public virtual void TrimToSize();
  19. D) public virtual object Dequeue();
  20. A) public BitArray Not();

Author

Shuseel Baral is a web programmer and the founder of InfoTechSite has over 8 years of experience in software development, internet, SEO, blogging and marketing digital products and services is passionate about exceeding your expectations.

Comments are closed.