Which of the following lines can be inserted at line 2 to print true? (Choose all that apply)
public class Main{ 1: public static void main(String[] args) { 2: // INSERT CODE HERE 3: } 4: private static boolean test(Predicate<Integer> p) { 5: return p.test(2); 6: } }
A, C, F.
Lambda expressions with one parameter can omit the parentheses around the parameter list, A and C are correct.
The return statement is optional when a single statement is in the body, therefor F is correct.
B is incorrect because a return statement must be used if braces are included around the body.
D and E are incorrect because the type is Integer in the predicate and int in the lambda.