Choose the correct option based on this program:.
import java.util.function.BiFunction; public class Main { public static void main(String args[]){ BiFunction<String, String, Boolean> compareString = (x, y) -> x.equals(y); System.out.println(compareString.apply("Java8","Java8")); // #1 } }
B.
the BiFunction interface takes two type arguments-they are of types String in this program.
the return type is Boolean.
BiFunction functional interface has abstract method named apply()
.
since the signature of String's equals()
method matches that of the signature of the abstract method apply()
, this program compiles fine.
When executed, the strings "Java8" and "Java8" are equal; hence, the evaluation returns true that is printed on the console.