What is the result?
A.
Three
B.
One
C.
Compilation fails.
D.
The program runs, but prints no output.
Explanation:
push
void push(E e)
Pushes an element onto the stack represented by this deque (in other words, at the head of this
deque) if it ispossible to do so immediately without violating capacity restrictions, returning true
upon success and throwingan IllegalStateException if no space is currently available.
This method is equivalent to addFirst(E).
pop
E pop()
Pops an element from the stack represented by this deque. In other words, removes and returns
the firstelement of this deque.
This method is equivalent to removeFirst().
Returns:
the element at the front of this deque (which is the top of the stack represented by this deque)
Throws:
NoSuchElementException – if this deque is empty
public static void main(String[] args) {
Deque deque=new ArrayDeque();
deque.add(“One”);
deque.add(“Two”);
deque.add(“Three”);
System.out.println(deque.pop());
}
//One
yup I got one as well
A