Collections and Generics in .NET Framework

Reviewed by Editorial Team
The ProProfs editorial team is comprised of experienced subject matter experts. They've collectively created over 10,000 quizzes and lessons, serving over 100 million users. Our team includes in-house content moderators and subject matter experts, as well as a global network of rigorously trained contributors. All adhere to our comprehensive editorial guidelines, ensuring the delivery of high-quality content.
Learn about Our Editorial Process
| By Themes
T
Themes
Community Contributor
Quizzes Created: 2163 | Total Attempts: 1,171,680
| Questions: 30 | Updated: Sep 7, 2026
Please wait...
Question 1 / 31
🏆 Rank #--
0 %
0/100
Score 0/100

1. Which method in List<T> is used to add items to the end of the list?

Explanation

In the List class, the Add() method is specifically designed to append an element to the end of the list. This method increases the size of the list by one and places the new item at the last position, ensuring that the list maintains its order. Other methods like Insert() or Push() serve different purposes, such as adding elements at specific indices or manipulating stack-like structures, respectively. Therefore, Add() is the appropriate choice for adding items to the end of a List.

Submit
Please wait...
About This Quiz
Collections and Generics In .Net Framework - Quiz

This assessment focuses on Collections and Generics in .NET Framework, evaluating your understanding of key concepts such as namespaces, collection types, and their operations. It's relevant for anyone looking to enhance their programming skills in C# and understand how to effectively use collections and generics in their applications.

2.

What first name or nickname would you like us to use?

You may optionally provide this to label your report, leaderboard, or certificate.

2. Match each collection class or interface with its correct description.

Submit

3. Generic collections avoid the creation of custom collections for each type in an application.

Submit

4. The SortedList class can only be accessed using an index value, not a key.

Submit

5. ArrayList is a dynamic collection, meaning items can be added and removed at runtime.

Submit

6. The ______ method in SortedList returns the boolean value true if the specified key exists in the collection.

Submit

7. The Queue collection follows the ______ principle.

Submit

8. The Stack collection follows the ______ principle.

Submit

9. What does the Pop() method do in a Stack<T>?

Submit

10. Which method in Stack<T> adds an element at the top of the stack?

Submit

11. Which method in Queue<T> removes and returns the value at the beginning of the queue?

Submit

12. What does the Peek() method do in a Queue<T>?

Explanation

The Peek() method in a Queue allows you to access the element at the front of the queue without modifying the queue itself. This means you can check what the next element to be processed is, while keeping it in the queue for future operations. It is useful for scenarios where you need to see the next item to be dequeued without actually removing it.

Submit

13. Which method in Queue<T> adds an element to the end of the queue?

Explanation

In a queue data structure, the primary operation for adding an element is typically referred to as "enqueue." This method places an item at the back of the queue, maintaining the first-in, first-out (FIFO) order. Other options like Push() or Add() may be used in different contexts or data structures but do not specifically denote the queue operation. Insert() is also more general and does not imply the specific behavior associated with queues. Thus, Enqueue() is the most appropriate method for this operation.

Submit

14. Which method in List<T> is used to sort the elements in the list?

Explanation

In the List class, the Sort() method is specifically designed to sort the elements in the list in ascending order. This method rearranges the elements based on their natural ordering or a specified comparer. By using Sort(), developers can efficiently organize data within a list, making it easier to search and manage. Other options like Order(), Arrange(), and Organize() do not exist as methods in the List class, making Sort() the only correct choice for this functionality.

Submit

15. What does the IndexOf() method return if the specified element is NOT found in a List<T>?

Explanation

The IndexOf() method in a List searches for a specified element and returns its zero-based index. If the element is not found, it returns -1, indicating the absence of the element in the list. This behavior is consistent across many programming languages, where -1 serves as a standard way to signify that an item could not be located within a collection. Thus, the return value of -1 effectively communicates that the search was unsuccessful.

Submit

16. Which namespace contains the standard collection classes in .NET Framework?

Explanation

The System.Collections namespace in the .NET Framework provides classes that define various non-generic collections, such as lists, queues, stacks, and dictionaries. These collections are designed to store and manage groups of objects. While System.Collections.Generic offers generic collections with type safety, System.Collections includes legacy collections that are still widely used for scenarios where type parameters are not necessary. Understanding these namespaces helps developers choose the appropriate collection type based on their specific needs.

Submit

17. What is the correct syntax for creating a List<T> collection in C#?

Explanation

To create a List collection in C#, the syntax requires the use of the `new` keyword followed by the type parameter in angle brackets, indicating the type of elements the list will hold. The correct syntax `List variableName = new List();` initializes a new instance of the List class and assigns it to the variable `variableName`. This ensures that the variable is properly instantiated and ready to store elements of type T, adhering to C#'s object-oriented principles.

Submit

18. Which generic collection provides an efficient and dynamically allocated array commonly used to store duplicate objects?

Explanation

List is a generic collection in .NET that provides a dynamically sized array, allowing for efficient storage and retrieval of elements. Unlike arrays, Lists can grow or shrink in size as needed, making them ideal for scenarios where the number of objects is not known in advance. Additionally, Lists can store duplicate objects, which is essential for applications that require the same item to be represented multiple times. This flexibility and capability to handle duplicates make List a popular choice for many developers.

Submit

19. What is the main purpose of Generics in C#?

Explanation

Generics in C# enable developers to define classes, interfaces, and methods with a placeholder for the data type, allowing the same code to work with different types without sacrificing type safety. This promotes code reusability and maintainability, as it reduces redundancy and the need for multiple implementations for different data types. By using generics, developers can create more flexible and efficient code, making it easier to manage and extend applications.

Submit

20. Which interface provides a list of elements accessible via a key or value rather than an index?

Explanation

IDictionary is an interface that allows access to a collection of key-value pairs, enabling retrieval of elements using keys instead of numeric indices. This is particularly useful for scenarios where quick lookups and associations between keys and their corresponding values are needed. Unlike IList, which operates on indexed elements, IDictionary provides methods for adding, removing, and checking for the existence of keys, making it ideal for applications requiring associative data structures.

Submit

21. Which interface allows you to determine the number of elements in a collection and copy them into a simple array?

Explanation

ICollection is an interface in the .NET Framework that provides methods for managing collections of objects. It allows you to determine the number of elements through the Count property and offers a method to copy the elements into an array using the CopyTo method. This makes ICollection particularly useful for handling collections where you need to know the size and also need to transfer the items to a simpler data structure like an array. Other interfaces like IEnumerable and IList do not provide both functionalities together as effectively.

Submit

22. Which interface in System.Collections allows you to loop through elements in a collection?

Explanation

IEnumerable is an interface in the System.Collections namespace that allows for iteration over a collection of objects. It provides a method called GetEnumerator, which returns an enumerator that can be used to traverse the collection. This makes it possible to use a foreach loop to access each element in the collection sequentially, making IEnumerable essential for any collection that needs to support simple iteration. Other interfaces like ICollection, IDictionary, and IList have additional functionalities but do not inherently provide the basic iteration capability that IEnumerable does.

Submit

23. What operations are used to add and remove objects from a Queue?

Explanation

In a Queue, the operations used to manage the addition and removal of objects are specifically termed "Enqueue" and "Dequeue." Enqueue refers to adding an item to the back of the queue, while Dequeue refers to removing an item from the front. This structure follows the First-In-First-Out (FIFO) principle, ensuring that the first item added is the first one to be removed, which is essential for maintaining order in processing tasks.

Submit

24. What operations are used to insert and remove objects from a Stack?

Explanation

In a stack data structure, the operations used to insert and remove objects are specifically termed "Push" and "Pop." "Push" refers to adding an item to the top of the stack, while "Pop" is the operation that removes the item from the top. This Last In, First Out (LIFO) principle defines how stacks operate, where the most recently added item is the first one to be removed. Other options like Enqueue and Dequeue are related to queues, not stacks.

Submit

25. Which collection class represents a First In, First Out (FIFO) collection of objects?

Explanation

A Queue is a collection class that follows the First In, First Out (FIFO) principle, meaning that the first element added to the queue will be the first one to be removed. This is analogous to a line of people waiting, where the first person to enter the line is the first to be served. In contrast, a Stack operates on a Last In, First Out (LIFO) basis, while Hashtable and SortedList serve different purposes related to key-value pairs and ordered collections, respectively. Thus, a Queue is specifically designed for FIFO operations.

Submit

26. Which collection class represents a Last In, First Out (LIFO) collection of objects?

Explanation

A Stack is a collection class that follows the Last In, First Out (LIFO) principle, meaning that the last element added to the stack is the first one to be removed. This behavior is akin to a stack of plates, where you can only remove the top plate. Stacks are commonly used in scenarios like undo mechanisms in applications, parsing expressions, and managing function calls in programming. Other options, like Queue and ArrayList, do not adhere to this LIFO structure, making Stack the appropriate choice for this characteristic.

Submit

27. SortedList is a combination of which two collection classes?

Explanation

SortedList combines the functionalities of an ArrayList and a Hashtable. It maintains a sorted collection of key-value pairs, where keys are stored in an array-like structure (similar to ArrayList), allowing for indexed access and ordered retrieval. At the same time, it provides efficient key-based lookups akin to a Hashtable, enabling quick access to values associated with specific keys. This dual nature allows SortedList to leverage the strengths of both collection types, offering both sorted order and fast retrieval capabilities.

Submit

28. Which collection class stores key-value pairs where the key must be specified to access values?

Explanation

Hashtable is a collection class in Java that stores data in key-value pairs. Each value is associated with a unique key, which must be specified to retrieve the corresponding value. This allows for efficient data retrieval, as the key acts as an identifier. Unlike ArrayList, Stack, or Queue, which are designed for ordered collections or specific data structures, Hashtable provides a way to access values directly through their keys, making it ideal for scenarios where quick lookups are necessary.

Submit

29. What type of collection is ArrayList known for?

Explanation

ArrayList is known for maintaining the order of elements based on their insertion sequence. This means that when elements are added to an ArrayList, they are stored in the order they were added, allowing for easy access and retrieval based on their index. Unlike static collections, ArrayLists can dynamically resize, and they do not utilize key-value pairs like maps. Additionally, they do not follow the last-in, first-out principle characteristic of stacks. Thus, the defining feature of an ArrayList is its capability to store an ordered collection of objects.

Submit

30. Which namespace contains the generic collection classes in .NET Framework?

Explanation

System.Collections.Generic is the namespace in the .NET Framework that provides classes for generic collections. These collections allow developers to create strongly typed collections that can store objects of a specified type, enhancing type safety and performance. This namespace includes popular generic collection classes such as List, Dictionary, and HashSet, which facilitate efficient data manipulation and retrieval while reducing the need for type casting.

Submit
×
Saved
Thank you for your feedback!
View My Results
Cancel
  • All
    All (30)
  • Unanswered
    Unanswered ()
  • Answered
    Answered ()
Which method in List<T> is used to add items to the end of the...
Match each collection class or interface with its correct description.
Generic collections avoid the creation of custom collections for each...
The SortedList class can only be accessed using an index value, not a...
ArrayList is a dynamic collection, meaning items can be added and...
The ______ method in SortedList returns the boolean value true if the...
The Queue collection follows the ______ principle.
The Stack collection follows the ______ principle.
What does the Pop() method do in a Stack<T>?
Which method in Stack<T> adds an element at the top of the...
Which method in Queue<T> removes and returns the value at the...
What does the Peek() method do in a Queue<T>?
Which method in Queue<T> adds an element to the end of the...
Which method in List<T> is used to sort the elements in the...
What does the IndexOf() method return if the specified element is NOT...
Which namespace contains the standard collection classes in .NET...
What is the correct syntax for creating a List<T> collection in...
Which generic collection provides an efficient and dynamically...
What is the main purpose of Generics in C#?
Which interface provides a list of elements accessible via a key or...
Which interface allows you to determine the number of elements in a...
Which interface in System.Collections allows you to loop through...
What operations are used to add and remove objects from a Queue?
What operations are used to insert and remove objects from a Stack?
Which collection class represents a First In, First Out (FIFO)...
Which collection class represents a Last In, First Out (LIFO)...
SortedList is a combination of which two collection classes?
Which collection class stores key-value pairs where the key must be...
What type of collection is ArrayList known for?
Which namespace contains the generic collection classes in .NET...
play-Mute sad happy unanswered_answer up-hover down-hover success oval cancel Check box square blue
Alert!