Curioustab
Aptitude
General Knowledge
Verbal Reasoning
Computer Science
Interview
Take Free Test
Aptitude
General Knowledge
Verbal Reasoning
Computer Science
Interview
Take Free Test
Generics Questions
C#.NET collections — Which of the following types are present in the System.Collections.Generic namespace? 1) Stack 2) Tree 3) SortedDictionary 4) SortedArray
C#.NET generics — What will the following code do? public class TestCuriousTab { public void TestSub
(M arg) { Console.Write(arg); } } class MyProgram { static void Main(string[] args) { TestCuriousTab tab = new TestCuriousTab(); tab.TestSub("CuriousTab "); tab.TestSub(4.2f); } }
C#.NET generics — What happens in this generic class when using an operator on T? public class Generic
{ public T Field; public void TestSub() { T i = Field + 1; } } class MyProgram { static void Main(string[] args) { Generic
gen = new Generic
(); gen.TestSub(); } }
C#.NET generics — Which statement about generic procedures (generic methods) is valid?
C#.NET generics — Which statement correctly states an advantage of generics?
.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.
C#.NET generics — What is the result of this code? public class Generic
{ public T Field; } class Program { static void Main(string[] args) { Generic
g = new Generic
(); g.Field = "Hello"; Console.WriteLine(g.Field); } }
C#.NET Generics — interpret the where-constraint. Given: public class MyContainer
where T : IComparable { // Insert code here } Which statements are valid? Class MyContainer requires that its type argument must implement the IComparable interface. The type argument of class MyContainer must be IComparable itself (not just implement it). The compiler will report an error for this block of code. This requirement placed on the type argument is called a constraint.
C#.NET Generics — multiple constraints: reference type + interface. Given: public class MyContainer
where T : class, IComparable { // Insert code here } Which statements are valid? MyContainer requires that its type argument implement IComparable. The compiler will report an error for this block of code. There are multiple constraints on the type argument. The type argument must be a reference type and must implement IComparable.