Java Queue MCQs with answers
80 questions tagged Java Queue, each with the correct answer and an explanation. Page 1 of 4.
- Which class allows elements to expire after a delay and appear in natural order?
- Which queue class in Java implements Comparable elements by priority?
- Which queue implementation is NOT thread-safe?
- What does `peek()` return when the queue is empty?
- Which method blocks until an element becomes available for removal?
- Which method blocks until space is available in BlockingQueue?
- Which of the following can be used as both stack and queue?
- Which Queue method is suitable when blocking behavior is not desired?
- Which class is an unbounded thread-safe queue based on linked nodes?
- What is the main difference between a Deque and a Queue?
- Which Queue method is atomic and thread-safe in a ConcurrentLinkedQueue?
- Which method is used to add an element to both ends in a Deque?
- Which queue is suitable for message-passing between threads?
- Which method retrieves, but does not remove, the head of the queue and throws an exception if the queue is empty?
- Which queue implementation can store elements with the same delay in any order?
- Which Java collection is best for implementing a breadth-first search?
- Which method is preferred over `add()` to avoid exceptions when inserting?
- What will `add(null)` do in a `LinkedList` used as a Queue?
- Which of the following queues orders elements in the order they were inserted?
- What is the result of calling `poll()` on an empty `LinkedList` used as a Queue?