Solved

Complete the Code to Sort the Employees Collection by Title

Question 28

Multiple Choice

Complete the code to sort the employees collection by title and within title by salary using a Comparator.Assume the method getSalary that returns an employee's salary as an integer and the method getTitle that returns an employee's title as a String.
Collections.sort(employees, Comparator___________________________) ;


A) .comparing(Employee::getSalary) .thenComparing(Employee::getTitle)
B) .comparing(Employee::getTitle) .thenComparing(Employee::getSalary)
C) .thenComparing(Employee::getSalary) .comparing(Employee::getTitle)
D) .thenComparing(Employee::getTitle) .comparing(Employee::getSalary)

Correct Answer:

verifed

Verified

Unlock this answer now
Get Access to more Verified Answers free of charge

Related Questions