exam questions

Exam 1z0-809 All Questions

View all questions & answers for the 1z0-809 exam

Exam 1z0-809 topic 1 question 15 discussion

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

Given the definition of the Country class:
public class country {
public enum Continent {ASIA, EUROPE}
String name;
Continent region;
public Country (String na, Continent reg) {
name = na, region = reg;
}
public String getName () {return name;}
public Continent getRegion () {return region;}
}
and the code fragment:
List<Country> couList = Arrays.asList (
new Country ("Japan", Country.Continent.ASIA),
new Country ("Italy", Country.Continent.EUROPE),
new Country ("Germany", Country.Continent.EUROPE));
Map<Country.Continent, List<String>> regionNames = couList.stream ()
.collect(Collectors.groupingBy (Country ::getRegion,
Collectors.mapping(Country::getName, Collectors.toList()))));
System.out.println(regionNames);

  • A. {EUROPE = [Italy, Germany], ASIA = [Japan]}
  • B. {ASIA = [Japan], EUROPE = [Italy, Germany]}
  • C. {EUROPE = [Germany, Italy], ASIA = [Japan]}
  • D. {EUROPE = [Germany], EUROPE = [Italy], ASIA = [Japan]}
Show Suggested Answer Hide Answer
Suggested Answer: A 🗳️
Community vote distribution
A (71%)
B (29%)

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
M_Jawad
Highly Voted 5 years, 1 month ago
the correct answer is A , tested...
upvoted 7 times
...
Innovation
Highly Voted 5 years, 1 month ago
A is correct
upvoted 6 times
griglad
3 years ago
No look at the order of enum values. Asia goes first and then Europe
upvoted 1 times
...
...
6c84cb9
Most Recent 7 months, 1 week ago
Online Java Compiler: {ASIA=[Japan], EUROPE=[Italy, Germany]}
upvoted 1 times
...
shivkumarx
1 year ago
Selected Answer: A
I got A but I got B when using Java 17
upvoted 1 times
...
asdfjhfgjuaDCV
1 year ago
B is the correct answer
upvoted 1 times
...
steefaand
1 year, 1 month ago
Selected Answer: A
Answer is A.
upvoted 1 times
...
Eden0516
1 year, 5 months ago
Selected Answer: B
Tested, answer is B
upvoted 1 times
...
duydn
1 year, 5 months ago
Selected Answer: B
the order follow the senquential of ENUM constants
upvoted 1 times
...
GaelBernard
1 year, 7 months ago
Selected Answer: A
Tested on JDoodle.com using JDK 8, 9, 10, 11, 17, always got the same result: A- {EUROPE=[Italy, Germany], ASIA=[Japan]}
upvoted 3 times
...
r1muka5
2 years ago
correct answer is B (with JDK8).
upvoted 1 times
...
mevlt
3 years ago
With JDK 8 the answer is B
upvoted 1 times
...
WilsonKKerll
3 years ago
Answer is B. Because: new country("Japan", country.Continent.ASIA) this code is first
upvoted 3 times
...
bnagaraja9099
3 years, 10 months ago
JDK 11 - returned A on testing.. {EUROPE=[Italy, Germany], ASIA=[Japan]}
upvoted 1 times
...
Svetleto13
3 years, 10 months ago
A,tested
upvoted 1 times
Svetleto13
3 years, 10 months ago
A with JDK14. B with JDK8.
upvoted 1 times
griglad
3 years ago
Yeah but we dont care about what JDK14 says as this exam is for JDK8
upvoted 1 times
...
Huim
3 years, 10 months ago
I use JDK15, answer is B
upvoted 3 times
Svetleto13
3 years, 9 months ago
Maybe i typed wrong somewhere,but its actually B on both JDK8 and JDK14.If you change continent places in main method output is different.
upvoted 2 times
...
...
...
...
Astelitik
4 years, 6 months ago
Answer is A. The order is important
upvoted 2 times
Astelitik
4 years, 6 months ago
Sorry, I meant B - {ASIA=[Japan], EUROPE=[Italy, Germany]}
upvoted 4 times
...
...
rameasy
4 years, 7 months ago
Ans: B.Tested.
upvoted 2 times
...
Choucou
5 years, 5 months ago
correct 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 ...
exam
Someone Bought Contributor Access for:
SAP-C02
Chennai, 1 minute ago