answer: A
List
forEach
default void forEach(Consumer<? super T> action)
There is syntax error with parentheses and generic type.
it should be this way
Consumer function = f->{System.out.println(f);};
or
Consumer<String> function = f->{System.out.println(f);};
In fact, the above answers are all wrong
A seems correct, but the writing in lambda is wrong
If rewritten as
# Consumer function = s -> System.out.println(s);
to compile normally
NOTICE: A is the correct but consumer is bad implement in the option because explicit paramater for lambda is (String f)->... and the compiler expect Object, the correct is :
1- Consumer x = x -> System.out.print(x)
or:
2- Consumer<String> x = (String f) -> .....
o
3- Consumer<String> x= f -> sout...
Actually answer A is also incorrect. As Consumer is actually Consumer<Object> so it expects an Object rather than a String. It would've worked if it were: f -> System.out.println(f);
forEach() accepts a Consumer, so correct answer is A.
Consumer function = f -> System.out.println(f);
upvoted 1 times
...
This section is not available anymore. Please use the main Exam Page.1z0-819 Exam Questions
Log in to ExamTopics
Sign in:
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.
Upvoting a comment with a selected answer will also increase the vote count towards that answer by one.
So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.
ASPushkin
1 year agoGalen86
1 year, 5 months agod7bb0b2
1 year, 8 months agod7bb0b2
1 year, 7 months ago[Removed]
1 year, 11 months agotmuralimanohar
2 years, 1 month agoStavok
2 years, 2 months agoMukes877
2 years, 2 months agoAnkit1010
2 years, 6 months ago