Hire QA – Specialized in QA Recruitment, Technical Interviews and Testing Solutions

What is Queue and Stack, list their differences?

Category: Java

Both Queue and Stack are used to store data before processing them. java.util.Queue is an interface whose implementation classes are present in java concurrent package. Queue allows retrieval of element in First-In-First-Out (FIFO) order but it’s not always the case.
There is also Deque interface that allows elements to be retrieved from both end of the queue.
Stack is similar to queue except that it allows elements to be retrieved in Last-In-First-Out (LIFO) order.
Stack is a class that extends Vector whereas Queue is an interface.

Leave a Reply

Your email address will not be published. Required fields are marked *