Examveda

What will be the output of the following C# code snippet?
public class Generic<T>
{
    Stack<T> stk = new Stack<T>();
    public void push(T obj)
    {
        stk.Push(obj);
    }
    public T pop()
    {
        T obj = stk.Pop();
        return obj;
    }
}
class Program
{
    static void Main(string[] args)
    {
        Generic<string> g = new Generic<string>();
        g.push(30);
        Console.WriteLine(g.pop());
        Console.ReadLine();
    }
}

A. 0

B. 30

C. Runtime Error

D. Compile time Error

Answer: Option B


Join The Discussion

Related Questions on Delegates and Events in C Sharp