There are two possible solutions for question 56 in the OCP Practice Exam.
Question:
56. How many changes do you need to make in order for this code to compile?
A. None
B. One
C. Two
D. Three
E. Four
Answer:
C. First, a method reference uses two colons, so it should be Ready::getNumber. Second, you can’t use generics with a primitive, so it should be Supplier<Double>. The rest of the code is correct, so Option C is correct.
The answer is correct, but there's another way to solve this by making three changes, making answer D also possible and correct:
First, a method reference uses two colons, so it should be Ready::getNumber. Second, you can’t use generics with a primitive, so it should be DoubleSupplier. Third, you need to replace the get() method by the getAsDouble() method defined in the DoubleSupplier interface.
I think these changes should also be considered or the question should be updated to ask for the minimum changes required.
Thanks!
JP