Question: Which method reference can replace the lambda on the second line so the output is the same? A. a::contains(b) B. a::contains C. String::contains(b) D. String::contains

Which method reference can replace the lambda on the second line so the output is the same? 

var s = "fish"; Predicate pred System.out.println(pred.test("fish", "is")); = (a) ->s.contains (a);

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.

var s = "fish"; Predicate pred System.out.println(pred.test("fish", "is")); = (a) ->s.contains (a);

Step by Step Solution

3.31 Rating (160 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

The code snippet provided declares a lambda expression that checks if the string s contains some oth... 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!