nerdexam
Oracle

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…

Java Class Design

Question

Given the following code fragment:

What is the result?

Exhibit

1Z0-804 question #32 exhibit

Options

  • AThree
  • BOne
  • CCompilation fails
  • DThe program runs, but prints no outout

How the community answered

(32 responses)
  • A
    6% (2)
  • B
    75% (24)
  • C
    3% (1)
  • D
    16% (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

#enum#switch statement#fall-through#control flow

Community Discussion

No community discussion yet for this question.

Full 1Z0-804 Practice