Java Deque MCQs with answers Page - 8

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 • 802.91K Points
Coach

Q. Which Deque method is equivalent to Stack’s peek()?

  • (A) peekLast()
  • (B) peekFirst()
  • (C) getLast()
  • (D) top()

A

Admin • 802.91K Points
Coach

Q. What does `removeLast()` return when the deque is empty?

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

A

Admin • 802.91K Points
Coach

Q. Which method returns the number of elements in a Deque?

  • (A) size()
  • (B) length()
  • (C) count()
  • (D) getSize()

A

Admin • 802.91K Points
Coach

Q. What is the return type of `pollFirst()`?

  • (A) boolean
  • (B) int
  • (C) Object
  • (D) Depends on the generic type

A

Admin • 802.91K Points
Coach

Q. Which is a common use-case of Deque in algorithm design?

  • (A) Priority sorting
  • (B) Depth-first traversal
  • (C) Sliding window problems
  • (D) Sorting data

A

Admin • 802.91K Points
Coach

Q. Which Deque implementation does not support null elements?

  • (A) LinkedList
  • (B) ArrayDeque
  • (C) PriorityQueue
  • (D) TreeSet

A

Admin • 802.91K Points
Coach

Q. Which method in Deque throws exception when removing from an empty deque?

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

A

Admin • 802.91K Points
Coach

Q. What is the time complexity of insertion at both ends in ArrayDeque?

  • (A) O(n)
  • (B) O(log n)
  • (C) O(1)
  • (D) O(n log n)

A

Admin • 802.91K Points
Coach

Q. Which method is best to implement LIFO with Deque?

  • (A) offerLast() and pollLast()
  • (B) push() and pop()
  • (C) addLast() and removeFirst()
  • (D) offerFirst() and peekLast()

A

Admin • 802.91K Points
Coach

Q. Which method would you use to block a thread until space is available at the tail?

  • (A) addLast()
  • (B) offerLast()
  • (C) putLast()
  • (D) push()
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