C MCQ Quiz Hub

Choose a topic to test your knowledge and improve your C skills

Which one of the following classes are present System.Collections.Generic namespace? 1. Stack 2. Tree 3. SortedDictionary 4. SortedArray





✅ Correct Answer: 3

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(); } }





✅ Correct Answer: 4

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





✅ Correct Answer: 3

Which of the following statements is valid about generic procedures in C#.NET?





✅ Correct Answer: 4

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); } }





✅ Correct Answer: 1

For the code snippet given below, which of the following statements is valid? public class Generic<T> { public T Field; } class Program { static void Main(string[ ] args) { Generic<String> g = new Generic<String>(); g.Field = "Hello"; Console.WriteLine(g.Field); } }





✅ Correct Answer: 1

For the code snippet given below, which of the following statements are valid? public class MyContainer<T> where T: IComparabte { // Insert code here } 1. Class MyContainer requires that it's type argument must implement IComparabte interface. 2. Type argument of class MyContainer must be IComparabte. 3. Compiler will report an error for this block of code. 4. This requirement on type argument is called as constraint.





✅ Correct Answer: 3

For the code snippet given below, which of the following statements are valid? public class MyContainer<T> where T: class, IComparable { //Insert code here } Class MyContainer requires that it's type argument must implement IComparable interface. Compiler will report an error for this block of code. There are multiple constraints on type argument to MyContainer class. Class MyContainer requires that its type argument must be a reference type and it must implement IComparable interface.





✅ Correct Answer: 2

Which of the following statements is valid about advantages of generics?





✅ Correct Answer: 3