C# Programming - Generics

Why should I learn to solve C# Programming questions and answers section on "Generics"?

Learn and practise solving C# Programming questions and answers section on "Generics" to enhance your skills so that you can clear interviews, competitive examinations, and various entrance tests (CAT, GATE, GRE, MAT, bank exams, railway exams, etc.) with full confidence.

Where can I get the C# Programming questions and answers section on "Generics"?

IndiaBIX provides you with numerous C# Programming questions and answers based on "Generics" along with fully solved examples and detailed explanations that will be easy to understand.

Where can I get the C# Programming section on "Generics" MCQ-type interview questions and answers (objective type, multiple choice)?

Here you can find multiple-choice C# Programming questions and answers based on "Generics" for your placement interviews and competitive exams. Objective-type and true-or-false-type questions are given too.

How do I download the C# Programming questions and answers section on "Generics" in PDF format?

You can download the C# Programming quiz questions and answers section on "Generics" as PDF files or eBooks.

How do I solve C# Programming quiz problems based on "Generics"?

You can easily solve C# Programming quiz problems based on "Generics" by practising the given exercises, including shortcuts and tricks.

Exercise : Generics - General Questions
  • Generics - General Questions
1.
Which one of the following classes are present System.Collections.Generic namespace?
  1. Stack
  2. Tree
  3. SortedDictionary
  4. SortedArray
1 and 2 only
2 and 4 only
1 and 3 only
All of the above
None of the above
Answer: Option
Explanation:
No answer description is available. Let's discuss.

2.
For the code snippet shown below, which of the following statements are valid?
public class Generic<T>
{
    public T Field; 
    public void TestSub()
    {
        T i = Field + 1;
    }
}
class MyProgram
{
    static void Main(string[] args)
    {
        Generic<int> gen = new Generic<int>();
        gen.TestSub();
    }
}
Addition will produce result 1.
Result of addition is system-dependent.
Program will generate run-time exception.
Compiler will report an error: Operator '+' is not defined for types T and int.
None of the above.
Answer: Option
Explanation:
No answer description is available. Let's discuss.

3.
Which of the following statements are valid about generics in .NET Framework?
  1. Generics is a language feature.
  2. We can create a generic class, however, we cannot create a generic interface in C#.NET.
  3. Generics delegates are not allowed in C#.NET.
  4. Generics are useful in collection classes in .NET framework.
  5. None of the above
1 and 2 Only
1, 2 and 3 Only
1 and 4 Only
All of the above
None of the above
Answer: Option
Explanation:
No answer description is available. Let's discuss.

4.
Which of the following statements is valid about generic procedures in C#.NET?
All procedures in a Generic class are generic.
Only those procedures labeled as Generic are generic.
Generic procedures can take at the most one generic parameter.
Generic procedures must take at least one type parameter.
None of the above.
Answer: Option
Explanation:
No answer description is available. Let's discuss.

5.
For the code snippet shown below, which of the following statements are valid?
public class TestIndiaBix
{
    public void TestSub<M> (M arg)
    {
        Console.Write(arg);
    }
}
class MyProgram
{
    static void Main(string[] args)
    {
        TestIndiaBix bix = new TestIndiaBix();
        bix.TestSub("IndiaBIX ");
        bix.TestSub(4.2f);
    }
}
Program will compile and on execution will print: IndiaBIX 4.2
A non generic class Hello cannot have generic subroutine.
Compiler will generate an error.
Program will generate a run-time exception.
None of the above.
Answer: Option
Explanation:
No answer description is available. Let's discuss.