- Online Exam Test Papers | - MCQs[multiple choice questions and answers ] | - Mock Test Papers | - Practice Papers | - Sample Test Papers |

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

1.It will print string "Hello" on the console.

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

3.Compiler will give an error.

4.Member Field of class Generic is not accessible directly.

Posted Date:-2021-02-25 10:20:32


More MCQS Questions and answers

Search