Given the code fragment:
List
UnaryOperator
codes.replaceAll(uo);
codes.forEach(c -> System.out.println(c));
What is the result?
Given the code fragment:
List
UnaryOperator
codes.replaceAll(uo);
codes.forEach(c -> System.out.println(c));
What is the result?
The code will result in a compilation error because the UnaryOperator<Double> uo expects a Double input, but the list codes contains Integer elements. Since Integer and Double are incompatible types, this mismatch will cause a compilation error when trying to apply the UnaryOperator to the list of Integers.
The 12th line of the program will compile error, because the generic type of List is Integer, but UnaryOperator uses Double, which is different, so the compilation error.
Answer is C. Tested.
Tested: C is the correct answer
C is answer as Integer cannot be cast to Double.
Answer is C.