1.  Are generics in C# are same as the generics in java and templates in C++ ?


Yes
No
May be
None of the mentioned


Answer

 Option

Although C# generics are similar to templates in C++ and generics in Java, they are not the same as either. In fact, there are some fundamental differences among these three approaches to generics

Workspace

Report
Mail id: Report Error:

Answer Workspace Report

2.  Which among the given classes is present in System.Collection.Generic.namespace ?


Stack
Tree
Sorted Array
All of the mentioned


Answer

 Option

No answer description available for this question.

Workspace

Report
Mail id: Report Error:

Answer Workspace Report

3.  For the code given below which statements are perfectly valid ?
public class Csharp
{
public void subject(S arg)
{
Console.WriteLine(arg);
}
}
class Program
{
static Void Main(string[] args)
{
Csharp c = new Csharp();
c.subject(‘‘hi’‘);
c.subject(20);
}
}


Run time exception error
Compile time error
Code runs successfully and prints required output
None of the mentioned


Answer

 Option

Ouput: hi 20

Workspace

Report
Mail id: Report Error:

Answer Workspace Report

4.  What is meant by the term generics ?


parameterized types
class
structure
interface


Answer

 Option

The term generics means parameterized types. Parameterized types are important because they enable us to create classes, structures, interfaces, methods, and delegates in which, the type of data upon which they operate is specified as a parameter.

Workspace

Report
Mail id: Report Error:

Answer Workspace Report

5.  Which of these is a correct way of defining generic method ?


name(T1, T2, …, Tn) { /* … */ }
public name { /* … */ }
class name[T1, T2, …, Tn] { /* … */ }
name{T1, T2, …, Tn} { /* … */ }


Answer

 Option

The syntax for a generic method includes a type parameter, inside angle brackets, and appears before the method’s return type. For static generic methods, the type parameter section must appear before the method’s return type.

Workspace

Report
Mail id: Report Error:

Answer Workspace Report