Independence Day Deal! Unlock 25% OFF Today – Limited-Time Offer - Ends In 00:00:00 Coupon code: SAVE25
Welcome to Pass4Success

- Free Preparation Discussions

Oracle Exam 1Z0-809 Topic 1 Question 32 Discussion

Actual exam question for Oracle's 1Z0-809 exam
Question #: 32
Topic #: 1
[All 1Z0-809 Questions]

Given the code fragment:

List codes = Arrays.asList (10, 20);

UnaryOperator uo = s -> s +10.0;

codes.replaceAll(uo);

codes.forEach(c -> System.out.println(c));

What is the result?

Show Suggested Answer Hide Answer
Suggested Answer: D

Contribute your Thoughts:

Louis
1 months ago
The real question is, why would anyone want to add 10.0 to a list of Integers? Sounds like a case of over-engineering if you ask me.
upvoted 0 times
Lindsay
3 days ago
It's important to understand the code logic before making assumptions about over-engineering.
upvoted 0 times
...
Lindsay
8 days ago
The result is B) 1020.
upvoted 0 times
...
Lindsay
12 days ago
I agree, it does seem unnecessary to add 10.0 to a list of Integers.
upvoted 0 times
...
...
Merissa
1 months ago
D) A NumberFormatException is thrown at run time. The code is trying to add a Double to an Integer, and that's just asking for trouble.
upvoted 0 times
Camellia
16 days ago
C) A compilation error occurs.
upvoted 0 times
...
Camellia
27 days ago
A) 20.030.0
upvoted 0 times
...
...
Adaline
2 months ago
Haha, I'm going with C) A compilation error occurs. The code looks like it's written in some alien language, so it's bound to have issues compiling.
upvoted 0 times
Leontine
14 days ago
I think it's B) 1020
upvoted 0 times
...
Robt
26 days ago
I agree with C) A compilation error occurs.
upvoted 0 times
...
Elfrieda
1 months ago
I'm going with A) 20.030.0
upvoted 0 times
...
Mona
1 months ago
I think it's B) 1020
upvoted 0 times
...
...
Evangelina
2 months ago
I think the answer is B) 1020. The replaceAll method modifies the list in-place, so the original integer values are still present.
upvoted 0 times
...
Erick
2 months ago
The correct answer is A) 20.0 30.0. The UnaryOperator uo is applied to each element in the list, adding 10.0 to each value.
upvoted 0 times
Glen
20 days ago
codes.forEach(c -> System.out.println(c)) prints out the modified elements.
upvoted 0 times
...
Marylyn
26 days ago
codes.replaceAll(uo) applies the UnaryOperator to each element in the list.
upvoted 0 times
...
Arlyne
27 days ago
The result is correct, the UnaryOperator adds 10.0 to each element in the list.
upvoted 0 times
...
Shanda
1 months ago
The UnaryOperator uo adds 10.0 to each element in the list.
upvoted 0 times
...
Yuriko
2 months ago
A) 20.0 30.0
upvoted 0 times
...
Yoko
2 months ago
A) 20.0 30.0
upvoted 0 times
...
...
Malinda
2 months ago
I agree with Osvaldo, because the UnaryOperator cannot be applied to List.
upvoted 0 times
...
Osvaldo
2 months ago
I believe the answer is C) A compilation error occurs.
upvoted 0 times
...
Melvin
3 months ago
I think the result will be 20.0 and 30.0.
upvoted 0 times
...

Save Cancel
az-700  pass4success  az-104  200-301  200-201  cissp  350-401  350-201  350-501  350-601  350-801  350-901  az-720  az-305  pl-300  

Warning: Cannot modify header information - headers already sent by (output started at /pass.php:70) in /pass.php on line 77