Given the following code fragment:
What is the result?
A.
Three
B.
One
C.
Compilation fails
D.
The program runs, but prints no outout
Explanation:
add
boolean add(E e)
Inserts the specified element into the queue represented by this deque (in other words, at the tail
of thisdeque) if it is possible to do so immediately without violating capacity restrictions, returning
true uponsuccess and throwing an IllegalStateException if no space is currently available. When
using acapacity-restricted deque, it is generally preferable to use offer.
This method is equivalent to addLast(E).
remove
E remove()
Retrieves and removes the head of the queue represented by this deque (in other words, the first
element ofThisdeque). This method differs from poll only in that it throws an exception if this deque
is empty.
This method is equivalent to removeFirst().
Returns:
Thehead of the queue represented by this deque
Class ArrayDeque
A
B is correct.
B