C# - Collection Classes Questions and Answers
Practice ModeShowing 10 of 39 questions
Q31
Which collection class is thread-safe by default
Answer: Option C
Explanation: Hashtable is thread-safe by default.
Q32
Which property returns the number of elements in a collection
Answer: Option C
Explanation: Count property gives the total number of elements.
Q33
Which collection is best suited for frequent insertions and deletions
Answer: Option C
Explanation: LinkedList is efficient for frequent insert and delete operations.
Q34
Which method removes all elements from a collection
Answer: Option C
Explanation: Clear() removes all elements from the collection.
Q35
Which collection stores data in unordered key-value pairs
Answer: Option B
Explanation: Dictionary does not maintain sorted order by default.
Q36
Which collection can store different data types together
Answer: Option C
Explanation: ArrayList can store different data types as objects.
Q37
Which method checks whether a key exists in Dictionary
Answer: Option C
Explanation: ContainsKey() checks for the existence of a key.
Q38
Which collection is recommended over ArrayList for better performance
Answer: Option C
Explanation: List<T> avoids boxing and unboxing, improving performance.
Q39
Which collection is used to represent a fixed-size collection
Answer: Option B
Explanation: Array has a fixed size once created.