Question: What is the output of the following code?
1 import java.util.function.*;
2 public class Printing {
3 public static void main(String...args) {
4 Supplier<String> s1 = String::new;
5 System.out.print(s1.get());
6 Supplier<Integer> s2 = Integer::new;
7 System.out.print(s2.get());}}
Choice:
A. no output
B. empty space followed by 0
C. 0
D. null0
E. nullnull
F. s1s2
G. code does not compile
H. code compiles but throw runtime exceptions.
Explain: Supplier functional interface takes no parameter, returns an object of the defined type. Line 4 declared a Supplier returns an object of type String. String::new is the function reference. Line 6 tries to defined a Supplier returns an object of type Integer. However, the error message is: