Question: You would like to group a list of students by last name and get the total number of groups. Which line of code accomplishes this, assuming you have a list of the Student data class?
- `println(students.groupBy{ it.lastName }.count())`
- `println(students.groupBy{ it.lastName.first() }.fold().count())`
- `println(students.groupingBy{ it.lastName.first() }.count())`
- `println(students.groupingBy{ it.lastName.first() }.size())`
Answer: The correct answer of the above question is Option A:`println(students.groupBy{ it.lastName }.count())`