What will be the output of following Java quiz on PriorityQueue ?
Answer
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
© 2016, https:. All rights reserved. On republishing this post, you must provide link to original post