nerdexam
Oracle

1Z0-809 · Question #13

Given: public class Emp { String fName; String lName; public Emp (String fn, String ln) { fName = fn; lName = ln; } public String getfName() { return fName; } public String getlName() { return…

The correct answer is A. .sorted(Comparator.comparing(Emp::getfName).reversed().thenComparing(Emp::getlName)). You've hit your session limit · resets 5:20pm (America/New_York)

Question

Given: public class Emp { String fName; String lName; public Emp (String fn, String ln) { fName = fn; lName = ln; } public String getfName() { return fName; } public String getlName() { return lName; } } and the code fragment: List<Emp> emp = Arrays.asList ( new Emp ("John", "Smith"), new Emp ("Peter", "Sam"), new Emp ("Thomas", "Wale") ); emp.stream() //line n1 .collect(Collectors.toList()); Which code fragment, when inserted at line n1, sorts the employees list in descending order of lName and then ascending order of fName?

Options

  • A.sorted(Comparator.comparing(Emp::getfName).reversed().thenComparing(Emp::getlName))
  • B.sorted(Comparator.comparing(Emp::getlName).thenComparing(Emp::getfName))
  • C.map(Emp::getfName).sorted(Comparator.reverseOrder())
  • D.map(Emp::getfName).sorted(Comparator.comparing(Emp::getlName).reversed())

How the community answered

(41 responses)
  • A
    78% (32)
  • B
    7% (3)
  • C
    12% (5)
  • D
    2% (1)

Explanation

You've hit your session limit · resets 5:20pm (America/New_York)

Community Discussion

No community discussion yet for this question.

Full 1Z0-809 Practice