Which of the following statements correctly specifies the use of lambda expressions and the comparing method of the Comparator functional interface to sort an array of countries by population, assuming the existence of a getPopulation method?
A) Arrays.sort(countries, Comparator.comparing(c1 -> c1.getPopulation() , c2 -> c2.getPopulation() ) ;
B) Arrays.sort(countries, comparing(c -> c.getPopulation() ) ) ;
C) Arrays.sort(countries, c -> c.getPopulation() ) ;
D) Arrays.sort(countries, Comparator.comparing(c -> c.getPopulation() ) ;
Correct Answer:
Verified
Q83: What must be true about the return
Q84: Suppose a developer gets class XYZ files
Q85: Which of the following classes implement the
Q86: The _ class contains a sort method
Q87: Suppose the call obj1.compareTo(obj2) returns 0.What can
Q89: The binarySearch method of the Collections class
Q90: Suppose you wish to implement the Comparable
Q91: If a call to the Arrays static
Q92: Suppose you wish to sort an array
Q93: The Comparable interface consists of a single
Unlock this Answer For Free Now!
View this answer and more for free by performing one of the following actions
Scan the QR code to install the App and get 2 free unlocks
Unlock quizzes for free by uploading documents