Java Quiz on PriorityQueue

What will be the output of following Java quiz on PriorityQueue ?


Java Quiz on PriorityQueue


PriorityQueue keeps elements sorted and it can have duplicates.

add() and offer() methods both offer same functionality.

poll() method removes the first element in queue and returns it, while peek() method returns the first element without removing it.

Correct answer : “Apple Apple Nokia Nokia”


You may also like

Top 10 popular and tricky Java puzzles

Top Java articles : March 2016

Best 25 Java articles on the web in 2015


© 2016, https:. All rights reserved. On republishing this post, you must provide link to original post

You may also like...

Leave a Reply.. code can be added in <code> </code> tags