What does `getLast()` do in a Deque?

  1. Returns and removes the last element
  2. Returns the last element without removing
  3. Inserts element at the end
  4. Removes the last element
Correct answer Returns the last element without removing

Explanation

`getLast()` retrieves but does not remove the last element. Throws exception if empty.

Update: Admin added a tag on this question

Topics

By Admin · · 22 views