Online Access Free 1Z0-851 Practice Test
Exam Code: | 1Z0-851 |
Exam Name: | Java Standard Edition 6 Programmer Certified Professional Exam |
Certification Provider: | Oracle |
Free Question Number: | 290 |
Posted: | Aug 28, 2025 |
Given that the elements of a PriorityQueue are ordered according to natural ordering, and:
2.import java.util.*;
3.public class GetInLine {
4.public static void main(String[] args) {
5.PriorityQueue<String> pq = new PriorityQueue<String>();
6.pq.add("banana");
7.pq.add("pear");
8.pq.add("apple");
9.System.out.println(pq.poll() + " " + pq.peek());
10.}
11.}
What is the result?
Given:
1.public class Breaker2 {
2.static String o = "";
3.public static void main(String[] args) {
4.z:
5.for(int x = 2; x < 7; x++) {
6.if(x==3) continue;
7.if(x==5) break z;
8.o = o + x;
9.}
10.System.out.println(o);
11.}
12.}
What is the result?
Given:
11.public class ItemTest {
12.private final int id;
13.public ItemTest(int id) { this.id = id; }
14.public void updateId(int newId) { id = newId; }
15.16.
public static void main(String[] args) {
17.ItemTest fa = new ItemTest(42);
18.fa.updateId(69);
19.System.out.println(fa.id);
20.}
21.}
What is the result?