AllInfoHub Logo

AllInfoHub – MCQ Practice

Collections Framework – Multiple Choice Questions (MCQs)

  1. 49. What is the purpose of the `peek()` method of the `Queue` interface?

    • A. To remove and return the head of the queue
    • B. To return the head of the queue without removing it
    • C. To add an element to the end of the queue
    • D. To check if the queue is empty
  2. 50. What is the purpose of the `poll()` method of the `Queue` interface?

    • A. To return the head of the queue without removing it
    • B. To add an element to the end of the queue
    • C. To remove and return the head of the queue
    • D. To check if the queue is empty
  3. 51. What is the purpose of the `offer()` method of the `Queue` interface?

    • A. To remove and return the head of the queue
    • B. To return the head of the queue without removing it
    • C. To add an element to the end of the queue (returns false if full)
    • D. To check if the queue is empty