1z0-816 Java SE 11 Programmer II

Loading demo links...

Showing 4–6 of 10 questions

Question 4

Given the declaration:

Examine this code fragment:

/* Loc1 */ class ProcessOrders { ... }

Which two annotations may be applied at Loc1 in the code fragment? (Choose two.)

Select all that apply, then click Submit answer.

  • @Resource(priority=100)

  • @Resource(priority=0)

  • @Resource(name=“Customer1”, priority=100)

  • @Resource(name=“Customer1”)

  • @Resource

Question 5

Given:

Which two are correct? (Choose two.)

Select all that apply, then click Submit answer.

  • The output will be exactly 2 1 3 4 5.

  • The program prints 1 4 2 3, but the order is unpredictable.

  • Replacing forEach() with forEachOrdered(), the program prints 2 1 3 4 5, but the order is unpredictable.

  • Replacing forEach() with forEachOrdered(), the program prints 1 2 3 4 5.

  • Replacing forEach() with forEachOrdered(), the program prints 2 1 3 4 5.

Question 6

Given:

You want the code to produce this output:

John

Joe

Jane

Which code fragment should be inserted on line 1 and line 2 to produce the output?

Select an option, then click Submit answer.

  • Insert Comparator on line 1. Insert
    public int compare(Person p1, Person p2) { return p1.name.compare(p2.name);
    } on line 2.

  • Insert Comparator on line 1. Insert
    public int compareTo(Person person) { return person.name.compareTo(this.name);
    } on line 2.

  • Insert Comparable on line 1. Insert
    public int compare(Person p1, Person p2) { return p1.name.compare(p2.name);
    } on line 2.

  • Insert Comparator on line 1. Insert
    public int compare(Person person) { return person.name.compare(this.name);
    } on line 2.