Help and support on OCA OCP Java Programmer Certification Questions
1Z0-808, 1Z0-809, 1Z0-815, 1Z0-816, 1Z0-817
Moderator: admin
dfigueira
Posts: 21 Joined: Thu May 05, 2016 2:50 am
Contact:
Post
by dfigueira » Thu Nov 26, 2020 6:37 pm
Couldn't this option be accepted as well?
Code: Select all
.collect(Collectors.filtering(p, Collectors.mapping(Book::getTitle, Collectors.toSet()));
It returns the same result as the options marked as correct.
admin
Site Admin
Posts: 10209 Joined: Fri Sep 10, 2010 9:26 pm
Contact:
Post
by admin » Thu Nov 26, 2020 10:22 pm
Yes, this is option 5 and it is marked as correct already.
If you like our products and services, please help us by posting your
review here .
teodorj
Posts: 33 Joined: Tue Jun 19, 2018 10:27 am
Contact:
Post
by teodorj » Thu Jan 07, 2021 2:36 am
for the third option to be correct
.collect(Collectors.partitioningBy(p, Collectors.mapping(Book::getTitle, Collectors.toSet())));
the return type should be
Map<Boolean, Set<String>> newBooks
But the option
.collect(Collectors.filtering(p, Collectors.mapping(Book::getTitle, Collectors.toSet()));
is incorrect in my side. Please see below.
admin
Site Admin
Posts: 10209 Joined: Fri Sep 10, 2010 9:26 pm
Contact:
Post
by admin » Thu Jan 07, 2021 3:04 am
Which version of which question bank are you using?
If you like our products and services, please help us by posting your
review here .
teodorj
Posts: 33 Joined: Tue Jun 19, 2018 10:27 am
Contact:
Post
by teodorj » Thu Jan 07, 2021 3:28 am
This is for IZ0-817 exam
Ihave the latest ets viewer
admin
Site Admin
Posts: 10209 Joined: Fri Sep 10, 2010 9:26 pm
Contact:
Post
by admin » Thu Jan 07, 2021 4:09 am
ok, I see that it is not updated in 817 question bank. Sorry about that. Updated now in v 1.20
If you like our products and services, please help us by posting your
review here .
teodorj
Posts: 33 Joined: Tue Jun 19, 2018 10:27 am
Contact:
Post
by teodorj » Thu Jan 07, 2021 4:22 am
my ets viewer did not see update on question bank
teodorj
Posts: 33 Joined: Tue Jun 19, 2018 10:27 am
Contact:
Post
by teodorj » Thu Jan 07, 2021 4:51 am
And also, some of the question in ETS does not have "*" in Discuss button when there are discussion in this forum
admin
Site Admin
Posts: 10209 Joined: Fri Sep 10, 2010 9:26 pm
Contact:
Post
by admin » Thu Jan 07, 2021 5:02 am
Yes, the matching algorithm for questions in the s/w with the subject in topics of the forum is not accurate because of same question appearing in different versions of the exam. It errs on the side of caution.
If you like our products and services, please help us by posting your
review here .
edufin166@yahoo.com
Posts: 24 Joined: Wed Sep 28, 2022 9:41 am
Contact:
Post
by edufin166@yahoo.com » Fri Jun 16, 2023 12:40 pm
Theis alternative "is .collect(Collectors.filtering(p, Collectors.mapping(Book::getTitle, Collectors.toSet())));"
should return Map<String,Set<String>>, but seems me that is returning Set<String>.
Is it really correct?
admin
Site Admin
Posts: 10209 Joined: Fri Sep 10, 2010 9:26 pm
Contact:
Post
by admin » Fri Jun 16, 2023 11:43 pm
The call to Collectors.mapping(Book::getTitle, Collectors.toSet()) converts a stream of Books into a Set of title string. This call is wrapped inside Collectors.filtering(p,...), which filters the Set of titles based on the given Predicate. So it returns a Set.
Why do you think it should return a Map?
You may also want to try compiling and running the given code.
If you like our products and services, please help us by posting your
review here .
pavvel
Posts: 12 Joined: Fri Dec 15, 2023 4:00 pm
Contact:
Post
by pavvel » Mon Apr 29, 2024 10:01 am
Code: Select all
Collectors.toCollection(TreeSet::new)
The first case should not work because toCollection accept Supplier. Comperr expected.
admin
Site Admin
Posts: 10209 Joined: Fri Sep 10, 2010 9:26 pm
Contact:
Post
by admin » Mon Apr 29, 2024 11:14 am
pavvel wrote: ↑ Mon Apr 29, 2024 10:01 am
Code: Select all
Collectors.toCollection(TreeSet::new)
The first case should not work because toCollection accept Supplier. Comperr expected.
Yes and TreeSet::new is a valid method reference that implements Supplier.
If you like our products and services, please help us by posting your
review here .
_umut_
Posts: 6 Joined: Sun Sep 15, 2024 12:42 am
Contact:
Post
by _umut_ » Wed Oct 02, 2024 2:57 am
I noticed a small discrepancy in the wording of this question that might be worth clarifying. The question asks for 'a set of books', but the code structure (Set<String>) suggests we're actually collecting book titles. Would it be more precise to say 'a set of book titles' in the question text, to distinguish it from book objects? This minor adjustment could help align the wording more closely with the expected code implementation.
admin
Site Admin
Posts: 10209 Joined: Fri Sep 10, 2010 9:26 pm
Contact:
Post
by admin » Wed Oct 02, 2024 3:43 am
Good point. Will update.
thank you for your feedback!
If you like our products and services, please help us by posting your
review here .
Users browsing this forum: Google [Bot] and 35 guests