A

Admin • 828.43K Points
Coach

Q. Which method throws an exception if the queue is empty while retrieving the head?

  • (A) poll()
  • (B) peek()
  • (C) element()
  • (D) get()
  • Correct Answer - Option(C)
  • Views: 22
  • Filed under category Java
  • Hashtags: Java Queue

Explanation by: Admin
`element()` retrieves the head but throws NoSuchElementException if the queue is empty.

You must be Logged in to update hint/solution

Discusssion

Login to discuss.

Be the first to start discuss.