About Question enthuware.ocajp.i.v8.2.1471 :

Help and support on OCA OCP Java Programmer Certification Questions
1Z0-808, 1Z0-809, 1Z0-815, 1Z0-816, 1Z0-817

Moderator: admin

Post Reply
Celina
Posts: 2
Joined: Thu Sep 06, 2018 5:31 am
Contact:

About Question enthuware.ocajp.i.v8.2.1471 :

Post by Celina »

Why below is wrong
() -> true
I saw in the OCA study book, the parameter can be 0 and below is valid
print(()->true);

admin
Site Admin
Posts: 10386
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.ocajp.i.v8.2.1471 :

Post by admin »

Did you read the explanation for this option? It explains why this is invalid.
As per the problem statement, you have to pick only such a lambda expression that can be used to invoke a method that accepts a java.util.function.Predicate.

() -> true is a valid lambda expression as such but it cannot implement a Predicate.

BespawlerC
Posts: 1
Joined: Sun Oct 28, 2018 12:02 pm
Contact:

Re: About Question enthuware.ocajp.i.v8.2.1471 :

Post by BespawlerC »

admin wrote:
Sun Oct 28, 2018 2:41 am
Did you read the explanation for this option? It explains why this is invalid.
As per the problem statement, you have to pick only such a lambda expression that can be used to invoke a method that accepts a java.util.function.Predicate.

() -> true is a valid lambda expression as such but it cannot implement a Predicate.
Very nicely explained :thumbup:

Celina
Posts: 2
Joined: Thu Sep 06, 2018 5:31 am
Contact:

Re: About Question enthuware.ocajp.i.v8.2.1471 :

Post by Celina »

admin wrote:
Sun Oct 28, 2018 2:41 am
Did you read the explanation for this option? It explains why this is invalid.
As per the problem statement, you have to pick only such a lambda expression that can be used to invoke a method that accepts a java.util.function.Predicate.

() -> true is a valid lambda expression as such but it cannot implement a Predicate.
Sorry English is my 2nd lanugage, just misunderstood the question , now I get it. Thanks.

alfredo.zuloaga
Posts: 10
Joined: Fri Nov 18, 2016 5:48 pm
Contact:

Re: About Question enthuware.ocajp.i.v8.2.1471 :

Post by alfredo.zuloaga »

This is also valid
Predicate predicate = x -> x == null;

admin
Site Admin
Posts: 10386
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.ocajp.i.v8.2.1471 :

Post by admin »

Yes, it is valid. You may try writing a simple test program to check it out.

Post Reply

Who is online

Users browsing this forum: No registered users and 7 guests