Welcome to ExamTopics
ExamTopics Logo
- Expert Verified, Online, Free.

Unlimited Access

Get Unlimited Contributor Access to the all ExamTopics Exams!
Take advantage of PDF Files for 1000+ Exams along with community discussions and pass IT Certification Exams Easily.

Exam 1z0-809 topic 1 question 164 discussion

Actual exam question from Oracle's 1z0-809
Question #: 164
Topic #: 1
[All 1z0-809 Questions]

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(scr));
What is the result?

  • A. A compilation error occurs.
  • B. Java EE Java ME
  • C. [Java EE: Helen:Houston] [Java ME: Jessy:Chicago, Java ME: Mark:Chicago]
  • D. [Java ME: Jessy:Chicago, Java ME: Mark:Chicago] [Java EE: Helen:Houston]
Show Suggested Answer Hide Answer
Suggested Answer: B 🗳️

Comments

Chosen Answer:
This is a voting comment (?) , you can switch to a simple comment.
Switch to a voting comment New
steefaand
2 months, 1 week ago
Selected Answer: B
Answer is B assuming typo in forEach line.
upvoted 1 times
...
duydn
7 months ago
Selected Answer: B
.forEach(src, res) -> System.out.println(scr)); -> i think this is typo -> B if type not considered
upvoted 1 times
duydn
7 months ago
*typo for line 2
upvoted 1 times
...
...
jduarte
3 years ago
Answer is A, but if change stds.stream().collect(Collectors.groupingBy(Student::getCourse)) .forEach((src,res) -> System.out.println(src)); the answer is B
upvoted 1 times
samtash1034
2 years, 3 months ago
missing one 「(」?
upvoted 1 times
...
...
jduarte
3 years, 2 months ago
Answer A. Tested
upvoted 2 times
maslac
3 years ago
it is if you take a typo in question, that is likely, into consideration when testing, but if you correct this line .forEach(src, res) -> System.out.println(scr)); ==========> .forEach(src, res) -> System.out.println(src)); Then answer is B
upvoted 2 times
...
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...