Question: Which lambda expression can replace the instance of new BiologyMaterial() in the Scientist class and produce the same results under various inputted values? A. (p,q)

Which lambda expression can replace the instance of new BiologyMaterial() in the Scientist class and produce the same results under various inputted values? 

package university; @FunctionalInterface interface Study { abstract int learn(String subject, int duration);

A. (p,q) -> q==null ? p : p+1

B. (c,d) -> {int d=1; return c!=null ? d+1 : d;}

C. (x,y) -> {return x==null ? y : y+1;}

D. (a,b) -> 1

E. None of the above.

package university; @FunctionalInterface interface Study { abstract int learn(String subject, int duration); } class BiologyMaterial implements Study { @Override public int learn (String subject, int duration) { if (subject == null) return duration; } } } else return duration+1; public class Scientist { public static void main(String[] courses) { final Study s = new BiologyMaterial(); System.out.print(s. Learn (courses [0], Integer.parseInt(courses [1])));

Step by Step Solution

3.47 Rating (154 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

To replace the new BiologyMaterial with a lambda expression we need to provide a lambda that matches ... 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!