Oracle
1Z0-809 · Question #13
1Z0-809 Question #13: Real Exam Question with Answer & Explanation
Sign in or unlock 1Z0-809 to reveal the answer and full explanation for question #13. The question stem and answer options stay visible for context.
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())
Unlock 1Z0-809 to see the answer
You've previewed enough free 1Z0-809 questions. Unlock 1Z0-809 for full answers, explanations, the timed quiz mode, progress tracking, and the master PDF. Question stem and options stay visible so you can still see what's on the exam.