What is the result?

Given the code fragment:
List<Integer> codes = Arrays.asList (10, 20);
UnaryOperator<Double> uo = s -> s +10.0;
codes.replaceAll(uo);
codes.forEach(c -> System.out.println(c));
What is the result?

Given the code fragment:
List<Integer> codes = Arrays.asList (10, 20);
UnaryOperator<Double> uo = s -> s +10.0;
codes.replaceAll(uo);
codes.forEach(c -> System.out.println(c));
What is the result?

A.
20.0
30.0

B.
10

C.
A compilation error occurs.

D.
A NumberFormatException is thrown at run time.



Leave a Reply 3

Your email address will not be published. Required fields are marked *


KashiHide

KashiHide

C is the correct answer.

smh

smh

C. does not compile because code is Integer not Double.

andrei

andrei

C
codes.replaceAll(uo) fails to compile. The type List is not applicable for the arguments (UnaryOperator)