Home » JAVA Programming » Generics » Question
  1. What is the output of this program?
    import java.util.*;
    class genericstack
    {
    Stack object = new Stack ();
    public void push(E obj)
    {
    object.push(obj);
    }
    public E pop()
    {
    E obj = object.pop();
    return obj;
    }
    }

    public class Output
    {
    public static void main(String args[])
    {
    genericstack genericObject = new genericstack();
    genericObject.push(50);
    System.out.println(genericObject.pop());
    }
    }
    1. 0
    2. 30
    3. 50
    4. Compilation Error
    5. Runtime Error
Correct Option: C

50



Your comments will be displayed only after manual approval.