Java Deque MCQs with answers Page - 3

You will find multiple-choice questions (MCQs) related to #Java Deque here. Go through these questions to prepare effectively for your upcoming exams and interviews.

To view the correct answer for any question, simply click the "Show Answer" button.

Have a question to share? Click on "Add Question" to contribute!

A

Admin • 825.56K Points
Coach

Q. Which Deque method throws an exception if the element cannot be added at the front?

  • (A) offerFirst()
  • (B) addFirst()
  • (C) push()
  • (D) insertFirst()

A

Admin • 825.56K Points
Coach

Q. Which Deque method is used to simulate queue behavior by adding to the rear?

  • (A) addFirst()
  • (B) push()
  • (C) offerLast()
  • (D) insertEnd()

A

Admin • 825.56K Points
Coach

Q. Which method in Deque returns but does not remove the first element?

  • (A) peekFirst()
  • (B) pop()
  • (C) pollFirst()
  • (D) getFirst()

A

Admin • 825.56K Points
Coach

Q. Which Deque method acts similarly to `Stack.pop()`?

  • (A) removeFirst()
  • (B) pop()
  • (C) pollFirst()
  • (D) dequeue()

A

Admin • 825.56K Points
Coach

Q. Which method in Deque is used to remove the last element and return it?

  • (A) pop()
  • (B) pollFirst()
  • (C) removeLast()
  • (D) dequeue()

A

Admin • 825.56K Points
Coach

Q. What will `peekLast()` return on an empty Deque?

  • (A) 0
  • (B) false
  • (C) null
  • (D) Throws an exception

A

Admin • 825.56K Points
Coach

Q. Which of the following is true for ArrayDeque?

  • (A) Allows null elements
  • (B) Thread-safe
  • (C) Does not allow null elements
  • (D) Maintains natural order

A

Admin • 825.56K Points
Coach

Q. Which of the following operations is not supported directly by Deque?

  • (A) Insertion at both ends
  • (B) Removal from both ends
  • (C) Random access by index
  • (D) Peeking from both ends

A

Admin • 825.56K Points
Coach

Q. Which Deque method throws NoSuchElementException if the Deque is empty?

  • (A) peekFirst()
  • (B) pollLast()
  • (C) removeFirst()
  • (D) offerFirst()

A

Admin • 825.56K Points
Coach

Q. What is the default capacity of an ArrayDeque?

  • (A) 10
  • (B) 16
  • (C) 32
  • (D) Unlimited
What's Tag

As you may know, questions are organized under broad categories. Each category can include various types of questions. For example, the "History" category might contain questions about the Revolt of 1857, Shivaji Maharaj, Ancient History, Buddhism, and more.

To further refine this organization, we've introduced tags, which act as sub-categories to group questions more specifically.

Verified users can add tags to any question. If you have any suggestions regarding this system, we'd love to hear from you. Contact Us

Learn More