250+ TOP MCQs on Data Structures-Queue and Answers

This set of Java Multiple Choice Questions & Answers on “Data Structures-Queue”.

You can ask your doctor or exercise expert if you do not have regular exercise or do not know how to exercise. This site provides information on how to take medicines and other health issues http://fruzenshtein.com/rx/53684 that require medicines. We do not sell the product, it is available for purchase in a retail store.

You can easily buy the cheapest cat food and still be sure to get some of the best brands of cat food that the industry has to offer. The drug is prescribed to millions of women every year and it is used in several of the Dihok buy cheap neurontin top fertility clinics in the world. The company is one of the most popular manufacturers of generic medications in the world.

1. Which of the below is not a subinterface of Queue?
a) BlockingQueue
b) BlockingEnque
c) TransferQueue
d) BlockingQueue

Answer: b
Clarification: BlockingQueue, TransferQueue and BlockingQueue are subinterfaces of Queue.

2. What is the remaining capacity of BlockingQueue whose intrinsic capacity is not defined?
a) Integer.MAX_VALUE
b) BigDecimal.MAX_VALUE
c) 99999999
d) Integer.INFINITY

Answer: a
Clarification: A BlockingQueue without any intrinsic capacity constraints always reports a remaining capacity of Integer.MAX_VALUE.

3. PriorityQueue is thread safe.
a) True
b) False

Answer: a
Clarification: PriorityQueue is not synchronized. BlockingPriorityQueue is the thread safe implementation.

4. What is difference between dequeue() and peek() function of java?
a) dequeue() and peek() remove and return the next time in line
b) dequeue() and peek() return the next item in line
c) dequeue() removes and returns the next item in line while peek() returns the next item in line
d) peek() removes and returns the next item in line while dequeue() returns the next item in line

Answer: c
Clarification: dequeue() removes the item next in line. peek() returns the item without removing it from the queue.

5. What is the difference between Queue and Stack?
a) Stack is LIFO; Queue is FIFO
b) Queue is LIFO; Stack is FIFO
c) Stack and Queue is FIFO
d) Stack and Queue is LIFO

Answer: a
Clarification: Stack is Last in First out (LIFO) and Queue is First in First out(FIFO).

6. What are the use of front and rear pointers in CircularQueue implementation?
a) Front pointer points to first element; rear pointer points to the last element
b) Rear pointer points to first element; front pointer points to the last element
c) Front and read pointers point to the first element
d) Front pointer points to the first element; rear pointer points to null object

Answer: c
Clarification: CircularQueue implementation is an abstract class where first and rear pointer point to the same object.

7. What is the correct method used to insert and delete items from the queue?
a) push and pop
b) enqueue and dequeue
c) enqueue and peek
d) add and remove

Answer: b
Clarification: enqueue is pushing item into queue; dequeue is removing item from queue; peek returns object without removing it from queue.
Stack uses push and pop methods. add and remove are used in the list.

8. Which data structure is used in Breadth First Traversal of a graph?
a) Stack
b) Queue
c) Array
d) Tree

Answer: b
Clarification: In Breadth First Traversal of graph the nodes at the same level are accessed in the order of retrieval (i.e FIFO).

9. Where does a new element be inserted in linked list implementation of a queue?
a) Head of list
b) Tail of list
c) At the centre of list
d) All the old entries are pushed and then the new element is inserted

Answer: b
Clarification: To maintain FIFO, newer elements are inserted to the tail of the list.

10. If the size of the array used to implement a circular queue is MAX_SIZE. How rear moves to traverse inorder to insert an element in the queue?
a) rear=(rear%1)+MAX_SIZE
b) rear=(rear+1)%MAX_SIZE
c) rear=rear+(1%MAX_SIZE)
d) rear=rear%(MAX_SIZE+1)

Answer: b
Clarification: The front and rear pointer od circular queue point to the first element.

To practice all areas of Java, here is complete set on Multiple Choice Questions and Answers on Java.

contest

Leave a Reply

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