Given the code fragment:
String str = "Java is a programming language";
ToIntFunction
System.out.println(x);
What is the result?
Given the code fragment:
String str = "Java is a programming language";
ToIntFunction
System.out.println(x);
What is the result?
A compilation error occurs at line n1 because the method reference 'str::indexOf' is invalid in this context. The indexOf method requires two arguments: the instance it is called on and the argument passed to it. However, the functional interface ToIntFunction<T> only allows one input argument, which causes a mismatch leading to a compilation error.
Answer is correct.
A, tested
A is the correct answer tested
A. Tested.
C is correct since indexOf requires 2 parameters (object that calls it and its argument). However only 1 parameter is provided.
Incorrect, the indexOf() method has an overload which just takes a single string parameter. Correct answer is A
Line n1 doesnt compile since indexOf requires 2 arguments.
A. Tested.
A, tested