Home Subjects C# Programming

C# Programming

C# and .NET for campus placement

60 Q 4 Topics Take Mock Test
Advertisement
Difficulty: All Easy Medium Hard 1–10 of 60
Topics in C# Programming
Q.1 Hard Collections
In a high-concurrency distributed system, which collection from System.Collections.Concurrent is best for one-to-many relationships?
A ConcurrentDictionary
B ConcurrentBag
C ConcurrentDictionary
D BlockingCollection
Correct Answer:  C. ConcurrentDictionary
EXPLANATION

For one-to-many relationships with concurrent access, combining ConcurrentDictionary with ConcurrentBag (or List) provides thread-safe multi-value storage per key.

Test
Q.2 Hard Collections
Which collection should be used when you need both indexed access and automatic sorting?
A List
B SortedSet
C SortedList (with integer keys as indices)
D Queue
Correct Answer:  C. SortedList (with integer keys as indices)
EXPLANATION

SortedList<K,V> maintains sorted order by keys and allows O(1) index-based access. SortedSet<T> doesn't support indexing.

Test
Q.3 Hard Collections
In a real-time cache system with limited memory, which collection supports automatic eviction of least recently used items?
A Dictionary
B MemoryCache from System.Runtime.Caching
C ConcurrentDictionary
D LinkedHashMap
Correct Answer:  B. MemoryCache from System.Runtime.Caching
EXPLANATION

MemoryCache provides LRU-style eviction and memory management policies. Basic collections don't have built-in LRU functionality.

Test
Q.4 Hard Collections
In a dictionary with 1000 items, what is the expected number of operations for TryGetValue() in C# 2024-25?
A 1 (O(1))
B 500 (O(n))
C 10 (O(log n))
D 1000 (O(n))
Correct Answer:  A. 1 (O(1))
EXPLANATION

TryGetValue() uses hashing for lookup, providing O(1) average case complexity regardless of dictionary size.

Test
Q.5 Hard Collections
Which LINQ method combines multiple sequences into a single result with cartesian product?
A Union()
B SelectMany()
C Concat()
D Merge()
Correct Answer:  B. SelectMany()
EXPLANATION

SelectMany() (also called flatMap in other languages) flattens nested sequences and creates a cartesian product of collections.

Test
Q.6 Hard Collections
In a real-time data processing application, which concurrent collection would be best for producer-consumer pattern?
A ConcurrentBag
B BlockingCollection
C ConcurrentQueue
D ConcurrentDictionary
Correct Answer:  B. BlockingCollection
EXPLANATION

BlockingCollection<T> supports blocking operations for producer-consumer patterns, allowing threads to wait for items or space.

Test
Q.7 Hard Collections
In a competitive exam scenario, if you need both fast lookup and sorted iteration, which should you choose?
A List + Sort
B SortedDictionary
C HashSet
D Dictionary + LINQ
Correct Answer:  B. SortedDictionary
EXPLANATION

SortedDictionary provides O(log n) lookup and maintains sorted order during iteration. Alternatives are slower or require post-processing.

Test
Q.8 Hard Collections
Which LINQ method should you use to get distinct elements from a List while maintaining performance?
A list.Where(x => !list.Skip(list.IndexOf(x)+1).Contains(x))
B list.Distinct()
C list.GroupBy(x => x).Select(g => g.First())
D new HashSet(list)
Correct Answer:  B. list.Distinct()
EXPLANATION

Distinct() is the standard LINQ method for removing duplicates. While HashSet works, Distinct() is more idiomatic.

Test
Q.9 Hard Collections
What happens when you call Clear() on a Dictionary?
A Dictionary becomes null
B All key-value pairs are removed, capacity unchanged
C Dictionary capacity is reduced to 0
D An exception is thrown
Correct Answer:  B. All key-value pairs are removed, capacity unchanged
EXPLANATION

Clear() removes all elements but doesn't deallocate capacity. The dictionary remains usable with count=0.

Test
Q.10 Hard Collections
Which collection type allows you to iterate in reverse order efficiently?
A Queue
B LinkedList
C Stack
D SortedSet
Correct Answer:  B. LinkedList
EXPLANATION

LinkedList<T> has Reverse enumerator for efficient reverse iteration. Others don't have built-in reverse iteration support.

Test

About C# Programming Practice on iGET

iGET offers 60+ free C# Programming MCQ questions covering all important topics. Each question is prepared by subject experts and comes with detailed explanations to help you understand concepts deeply, not just memorize answers.

Why prepare with iGET?

100% free access, timed mock tests, instant results with detailed analysis, topic-wise progress tracking, and bookmark feature for revision. Trusted by thousands of aspirants preparing for UPSC, SSC, Bank, Railway, NEET, JEE and other competitive exams across India.

How to use this page effectively

Start by selecting a difficulty level (Easy / Medium / Hard) or pick a specific topic from the topics strip. Attempt questions, check your answer instantly, read the explanation carefully, and bookmark tricky ones for later revision. For full exam-style practice, take a Mock Test from the right sidebar.

IGET
IGET AI
Online · Exam prep assistant
Hi! 👋 I'm your iget AI assistant.

Ask me anything about exam prep, MCQ solutions, study tips, or strategies! 🎯
UPSC strategy SSC CGL syllabus Improve aptitude NEET Biology tips