Generics

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

A
It will print string 'Hello' on the console.

B
Name Generic cannot be used as a class name because it's a keyword.

C Compiler will give an error.

D
Member Field of class Generic is not accessible directly.

E None of the above.

ANS:A -

It will print string 'Hello' on the console.

No answer description is available. Let's discuss.



img not found
img

For help Students Orientation
Mcqs Questions

One stop destination for examination, preparation, recruitment, and more. Specially designed online test to solve all your preparation worries. Go wherever you want to and practice whenever you want, using the online test platform.