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 Result
    {
    public static void main(String args[])
    {
    genericstack genericstackObj0 = new genericstack();
    genericstackObj0.push("Inteview");
    System.out.print(genericstackObj0.pop() + " ");
    genericstack genericstackObj1 = new genericstack();
    genericstackObj1.push("Mania");
    System.out.println(genericstackObj1.pop());
    }
    }
    1. Mania
    2. Interview
    3. InterviewMnai
    4. Inerview Mania
    5. None of these
Correct Option: D

Inerview Mania



Your comments will be displayed only after manual approval.