フリー問題

Java SE 21 Developer Professional のフリー問題 13 / 20 問目

問題文

An ArrayDeque is used as a stack. Which pair of operations pushes an element and then removes the most recently pushed element?

選択肢

  1. add followed by remove, because the single argument forms of those two methods are defined to work on the same end of the deque as push and pop do.
  2. push followed by pop, both of which operate on the head of the deque, so the element added last is the one that leaves.
  3. offer followed by poll, both of which operate on the head of the deque and therefore produce last in first out behavior for the caller.
  4. push followed by poll, which work on opposite ends, and so an element that arrived first is one that leaves first.

解答・解説を確認するには

正解と解説の確認、回答の記録には無料登録が必要です。登録すると演習モードでフリー問題に回答し、正誤と解説をその場で確認できます。