.NET Framework generics — Which statements are valid? 1) Generics is a language feature. 2) We can create a generic class, however, we cannot create a generic interface in C#.NET. 3) Generic delegates are not allowed in C#.NET. 4) Generics are useful in collection classes in the .NET Framework. 5) None of the above.
-
A1 and 2 Only
-
B1, 2 and 3 Only
-
C1 and 4 Only
-
DAll of the above
-
ENone of the above
Answer
Correct Answer: 1 and 4 Only
Explanation
Introduction / Context:This question checks fundamental facts about generics across the C# language and the .NET class libraries, especially interfaces, delegates, and collections.
Given Data / Assumptions:
- We evaluate four claims about generics; item 5 is a distractor.
- We consider standard C# and the Base Class Library.
Concept / Approach:(1) True: Generics are a language (and CLR) feature enabling parameterized types. (2) False: C# supports generic interfaces, e.g., IEnumerable
Step-by-Step Solution:
Mark 1 as true.Mark 2 as false (many generic interfaces exist).Mark 3 as false (Func/Action are generic delegates).Mark 4 as true (generics power most collections).Therefore, the correct grouping is 1 and 4 only.Verification / Alternative check:Open any project and use IEnumerable
Why Other Options Are Wrong:They include false statements 2 and/or 3, or claim all/none are correct.
Common Pitfalls:Confusing earlier .NET 1.x collections (non-generic) with the generic collections introduced later.
Final Answer:1 and 4 Only