Given a Member class with fields for name and yearsMembership, including getters and setters and a print method, and a list of clubMembers members: Which two Stream methods can be changed to use method references? (Choose two.)
A.
.filter(Integer::equals(0))
B.
.map(testName::compareToIgnoreCase)
C.
.filter(Member::getYearsMembership() >= testMembershipLength)
answer: BD
A. Failed
The Basic format of a method reference is broadly <scope>::<method-name> without parameter names.
C Failed
The Basic format of a method reference is broadly <scope>::<method-name> without parameter names.
But here there is an boolean expression at the right hand.
B correct
Reference to an instance method of a particular object
containingObject::instanceMethodName
D. correct
Reference to an instance method of an arbitrary object of a particular type
ContainingType::methodName
B & D are correct.
A : .filter(Integer::equals(0)); You cannot pass parameter when calling through reference
C: .filter(Member::getYearsMembership() >= testMembershipLength); You cannot call method reference with '()'
B and D are correct because method reference is used only for reference method and constructor not for performing comparison
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
10 months agorami_mlaiel
1 year, 2 months agod7bb0b2
1 year, 5 months ago[Removed]
1 year, 10 months agoMukes877
2 years ago