Oracle
1Z0-809 · Question #254
Given: ``java class Student { String course, name, city; public Student(String name, String course, String city) { this.course = course; this.name = name; this.city = city; } public String…
The correct answer is A. [Java EE: Helen;Houston] [Java ME: Jessy,Chicago, Java ME: Mark;Chicago]. You've hit your session limit · resets 5:20pm (America/New_York)
Question
Given:
class Student {
String course, name, city;
public Student(String name, String course, String city) {
this.course = course; this.name = name; this.city = city;
}
public String toString() {
return course + ":" + name + ";" + city;
}
public String getCourse() { return course; }
public String getName() { return name; }
public String getCity() { return city; }
}
And the code fragment:
List<Student> stds = Arrays.asList(
new Student ("Jessy", "Java ME", "Chicago"),
new Student ("Helen", "Java EE", "Houston"),
new Student ("Mark", "Java ME", "Chicago"));
stds.stream()
.collect(Collectors.groupingBy(Student::getCourse))
.forEach((src, res) -> System.out.println(src));
What is the result?Options
- A[Java EE: Helen;Houston] [Java ME: Jessy,Chicago, Java ME: Mark;Chicago]
- BJava EE Java ME
- C[Java ME: Jessy,Chicago, Java ME: Mark;Chicago] [Java EE: Helen;Houston]
- DA compilation error occurs.
How the community answered
(29 responses)- A72% (21)
- B17% (5)
- C3% (1)
- D7% (2)
Explanation
You've hit your session limit · resets 5:20pm (America/New_York)
Community Discussion
No community discussion yet for this question.