Question: Which method reference can replace the lambda on the first line so the output is the same? BiPredicate pred = (a,b) -> a.contains(b); System.out.println(pred.test(fish,

Which method reference can replace the lambda on the first line so the output is the same?
BiPredicate pred = (a,b) -> a.contains(b);
System.out.println(pred.test("fish", "is"));

A. a::contains(b)

B. a::contains

C. String::contains(b)

D. String::contains

E. The supplied code does not compile.

F. None of the above.

Step by Step Solution

3.50 Rating (153 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

The correct answer is D Stringcontains Method references are an alternative syntax for lambda expres... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Oracle Questions!