🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: Monotonic Stack: all 13 questions

Quiz: Monotonic Stack · Question 8 of 13

In Java, which type is recommended for a stack?

In Java, which type is recommended for a stack?

  1. A.java.util.Stack
  2. B.ArrayDeque (used through the Deque interface)
  3. C.LinkedList only
  4. D.int[] with no counter
Answer & explanation

Correct answer: ArrayDeque (used through the Deque interface)

Stack is an old synchronised class; ArrayDeque is faster and is the recommended stack and queue.

Can you get the rest right without peeking?

Take the timed Quiz: Monotonic Stack quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →