exam questions

Exam 1z0-819 All Questions

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

Exam 1z0-819 topic 1 question 12 discussion

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

Given the code fragment:

What is the result?

  • A. EUR -> 0.84 -

    GBP -> 0.75 -

    USD -> 1.00 -
    CNY -> 6.42
  • B. The compilation fails.
  • C. CNY -> 6.42 -

    EUR -> 0.84 -

    GBP -> 0.75 -
    USD -> 1.00
  • D. USD -> 1.00 -

    GBP -> 0.75 -

    EUR -> 0.84 -
    CNY -> 6.42
Show Suggested Answer Hide Answer
Suggested Answer: C 🗳️

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
ASPushkin
3 months, 4 weeks ago
Selected Answer: C
d7bb0b2 - right approach (see below) notice different sorting in the answer. let's figure out where the sorting comes from. Collectors.toMap(i->symbols.get(i), i->1.0/exchangeRate.get(i))); Sort by alphabet So, answer: C
upvoted 1 times
...
Bugmenot240411
8 months ago
Selected Answer: C
C is the correct answer
upvoted 1 times
...
d7bb0b2
1 year ago
C is correct 1- first map not considered order. (stream) {EUR=0.8354916868577157, GBP=0.7544322897019993, USD=1.0, CNY=6.418098009491084} 2- second map sorted by natural order of the key and uses linkedhash, then output format values to two decimal CNY -> 6.42 EUR -> 0.84 GBP -> 0.75 USD -> 1.00
upvoted 1 times
d7bb0b2
1 year ago
notice: value is not important in this case, only key
upvoted 1 times
...
...
duydn
1 year, 2 months ago
Selected Answer: C
class Test { public static void main(String[] args) throws IOException { var symbols = List.of("USD", "GBP", "EUR", "CNY"); var exchangeRate = List.of(1.0, 1.3255, 1.1969, 0.1558094); var map1 = IntStream.range(0, Math.min(symbols.size(), exchangeRate.size())).boxed() .collect(Collectors.toMap(i -> symbols.get(i), i-> 1.0 / exchangeRate.get(i))); var map2 = map1.entrySet().stream() .sorted(Map.Entry.comparingByKey()) .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (oldValue, newValue) -> oldValue, LinkedHashMap::new)); map2.forEach((var k, var v) -> System.out.printf("%s -> %.2f\n", k, v)); } } -> C
upvoted 1 times
...
ue02765
1 year, 2 months ago
Selected Answer: C
run: CNY -> 6,42 EUR -> 0,84 GBP -> 0,75 USD -> 1,00 BUILD SUCCESSFUL (total time: 0 seconds)
upvoted 1 times
...
Stavok
1 year, 7 months ago
Selected Answer: C
C is correct
upvoted 1 times
...
pikosss
1 year, 10 months ago
Selected Answer: C
C is Correct
upvoted 3 times
...
RP384
1 year, 11 months ago
Selected Answer: C
This compiles fine
upvoted 3 times
...
RP384
1 year, 11 months ago
Correct answer: C
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:
SY0-701
London, 1 minute ago