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(100);
    System.out.println(genericObject.pop());
    }
    }
    1. 10
    2. 20
    3. 30
    4. 40
    5. 100
Correct Option: E

100



Your comments will be displayed only after manual approval.