Exam Permalink:
https://www.jobilize.com/java-certification-questions
Question Permalink:
https://www.jobilize.com/priorityqueue-methods-in-java
Question 208 / 297:  What can be inserted, independently, at line // insert code here to cause the program to print out : [3, 4, 7, 0]
Choose 3
import java.util.*;

public class Test {

public static void main(String[] args) {

Queue<Integer> queue = new LinkedList<Integer>();

queue.add(1);

queue.add(3);

queue.add(4);

queue.add(7);

// insert code here

System.out.println(queue);

}

}

<< First < Previous Next > Last >>
Explanation:

poll(): retrieves and removes the head of this queue, or null if this queue is empty.

peek(): retrieves, but does not remove, the head of this queue, returning null if this queue is empty.

offer(): inserts the specified element into this priority queue.

Exam Home Page
https://www.jobilize.com/java-certification-questions

Oracle Certified Professional Java Programmer

Author:

Access: Public Instant Grading

Ask
Edgar Delgado
Start Quiz
Tess Armstrong
Start Quiz
Vanessa Soledad
Start Exam
Madison Christian
Start Exam
Copy and paste the following HTML code into your website or blog.
<iframe src="https://www.jobilize.com/embed/java-certification-questions" width="600" height="600" frameborder="0" marginwidth="0" marginheight="0" scrolling="yes" style="border:1px solid #CCC; border-width:1px 1px 0; margin-bottom:5px" allowfullscreen webkitallowfullscreen mozallowfullscreen> </iframe>