Solved

Which of the Following Statements Correctly Specifies the Use of Lambda

Question 20

Multiple Choice

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:

verifed

Verified

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

Related Questions