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<int> g = new Generic<int>();
        g.push("Csharp");
        Console.WriteLine(g.pop());
        Console.ReadLine();
    }
}

A. Compile time error

B. Csharp

C. 0

D. Run time error

Answer: Option B


This Question Belongs to C Sharp Programming >> Networking In C Sharp

Join The Discussion

Related Questions on Networking in C Sharp

What is the difference between TCP and UDP in networking?

A. TCP provides reliable, connection-oriented communication, while UDP provides unreliable, connectionless communication

B. TCP provides unreliable, connectionless communication, while UDP provides reliable, connection-oriented communication

C. TCP is faster than UDP

D. UDP is more secure than TCP