Java.Collections.Who extends whom: Queue extends Deque, or Deque extends Queue?

✅ The correct answer is:

Deque extends Queue


Why?

  • Queue is more general — it defines FIFO behavior.
  • Deque (Double Ended Queue) is more specific, allowing insertion/removal at both ends, so it extends the basic Queue contract.

📚 From the Java hierarchy:

public interface Collection<E> { ... }

public interface Queue<E> extends Collection<E> { ... }

public interface Deque<E> extends Queue<E> { ... }

So the hierarchy is:

Collection
   ↑
 Queue
   ↑
 Deque

This makes sense semantically too — every Deque is a Queue, but not every Queue is a Deque.

This entry was posted in Без рубрики. Bookmark the permalink.