-
What is the output of this program?
import java.util.*;
public class stack_Example
{
public static void main(String args[])
{
Stack object = new Stack();
object.push(new Integer(20));
object.push(new Integer(12));
object.pop();
object.push(new Integer(60));
System.out.println(object);
}
}
-
- [20, 60]
- [20, 12, 60]
- [20, 12]
- [12, 60]
- None of these
Correct Option: A
push() and pop() are standard functions of the class stack, push() inserts in the stack and pop removes from the stack. 20 & 12 are inserted using push() the pop() is used which removes 12 from the stack then again push is used to insert 60 hence stack contains elements 20 & 60.