Choose the correct option based on this program:
import java.util.function.ObjIntConsumer; public class Main { public static void main(String []args) { ObjIntConsumer<String> charAt = (str, i) -> str.charAt(i); // #1 System.out .println(charAt.accept("java", 2)); // #2 } }
d.
ObjIntConsumer operates on the given String argument str and int argument i and returns nothing.
though the charAt method is declared to return the char at given index i, the accept method in ObjIntConsumer has return type void.
since System.out.println expects an argument to be passed, the call charAt.accept("java", 2) results in a compiler error because accept()
method returns void.