C# - Collection Classes Questions and Answers
C# Collection Classes questions with answers are highly useful for mastering data storage and manipulation techniques in programming. Topics like Lists, Dictionaries, Queues, and HashSets are frequently tested in programming interviews and coding assessments. Practicing programming questions and answers with explanations helps students improve their understanding of C# data structures and performance optimization. Such programming MCQs and problem-based aptitude questions are commonly asked in technical interviews and placement tests conducted by companies like Microsoft, TCS, and Infosys. Strengthen your skills through C# programming test practice and learn to use collections efficiently.
Questions on data collections in C language. Broaden skills with arrays and pointers
C# - Collection Classes
11. Which of the following is an ordered collection class? Map Stack Queue BitArray HashTable
- 1 only
- 2 and 3 only
- 4 and 5 only
- All of the above
12. Which of the following is the correct way to find out the number of elements currently present in an ArrayList Collection called arr?
- arr.Count
- arr.GrowSize
- arr.MaxIndex
- arr.Capacity
13. Which of the following statements are correct about a HashTable collection? It is a keyed collection. It is a ordered collection. It is an indexed collection. It implements a IDictionaryEnumerator interface in its inner class. The key - value pairs present in a HashTable can be accessed using the Keys and Values properties of the inner class that implements the IDictionaryEnumerator interface.
- 1 and 2 only
- 1, 2 and 3 only
- 4 and 5 only
- 1, 4 and 5 only
14. Which of the following statements are correct about the Collection Classes available in Framework Class Library?
- Elements of a collection cannot be transmitted over a network.
- Elements stored in a collection can be retrieved but cannot be modified.
- It is not easy to adopt the existing Collection classes for newtype of objects.
- Elements stored in a collection can be modified only if allelements are of similar types.
15. Which C# collection allows dynamic resizing and stores elements as objects
- Array
- Explanation: ArrayList can grow or shrink dynamically and stores elements as object type.
- Stack
- Queue
16. Which namespace contains most of the generic collection classes in C#
- System
- System.IO
- Explanation: Generic collections like List<T> and Dictionary<T,K> are in System.Collections.Generic.
- System.Linq
17. Which collection stores elements in key-value pairs
- List
- Stack
- Explanation: Dictionary stores data as key and value pairs.
- Queue
18. Which collection follows Last In First Out principle
- Queue
- List
- Explanation: Stack works on LIFO principle.
- Hashtable
19. Which collection follows First In First Out principle
- Stack
- Explanation: Queue works on FIFO principle.
- Dictionary
- ArrayList
20. Which generic collection is type-safe
- ArrayList
- Hashtable
- Explanation: List<T> ensures type safety using generics.
- Stack