1Z0-804 · Question #32
Given the following code fragment: What is the result?
The correct answer is B. One. 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…
Question
Given the following code fragment:
What is the result?
Exhibit
Options
- AThree
- BOne
- CCompilation fails
- DThe program runs, but prints no outout
How the community answered
(32 responses)- A6% (2)
- B75% (24)
- C3% (1)
- D16% (5)
Explanation
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). 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 This method is equivalent to removeFirst(). Thehead of the queue represented by this deque Class ArrayDeque
Topics
Community Discussion
No community discussion yet for this question.
