Page 1 of 1

About Question enthuware.ocpjp.v17.2.3729 :

Posted: Sat Nov 04, 2023 5:48 pm
by Tester
1. spliterator() is a default method in Collection, so all Collections have it.
Does Map have it?

Re: About Question enthuware.ocpjp.v17.2.3729 :

Posted: Sat Nov 04, 2023 7:55 pm
by admin
Is Map a Collection (with uppercase C)?

Re: About Question enthuware.ocpjp.v17.2.3729 :

Posted: Sun Nov 05, 2023 5:22 am
by Tester
admin wrote:
Sat Nov 04, 2023 7:55 pm
Is Map a Collection (with uppercase C)?
Sorry, I asked you a question and got a new question. Could you please correct mistake if it is?

Re: About Question enthuware.ocpjp.v17.2.3729 :

Posted: Sun Nov 05, 2023 6:30 am
by admin
As the quoted statement says, the spliterator() method is defined in the Collection interface. Map is not a Collection because it does not extend Collection interface.

If you are ever in doubt about whether a class has a method, just refer the JavaDoc API documentation. For example: https://docs.oracle.com/en/java/javase/ ... l/Map.html

Re: About Question enthuware.ocpjp.v17.2.3729 :

Posted: Mon Nov 06, 2023 2:46 am
by Tester
Depend on English description
https://www.collinsdictionary.com/dicti ... collection

its collection. Depend on your own description what does it mean Java collection, its not.
Could you please add what does it mean a collection in Java/Oracle World?
Personally for me Map is a collection because it group similar objects.

Re: About Question enthuware.ocpjp.v17.2.3729 :

Posted: Mon Nov 06, 2023 5:23 am
by admin
That is why I wrote Collection with a captial/uppercase C. When you say something is a Collection, it has a precise meaning in Java. It means that that something implements Collection interface. Map does not. My or your personal view does not matter.

Re: About Question enthuware.ocpjp.v17.2.3729 :

Posted: Mon Nov 06, 2023 6:41 am
by Tester
FYI:
https://docs.oracle.com/javase/8/docs/a ... ction.html
A collection represents a group of objects, known as its elements.
but on the other hand it tells
The root interface in the collection hierarchy.
With "c" in "Collection"
if we take a look here:
https://docs.oracle.com/javase/tutorial ... index.html
A collection — sometimes called a container — is simply an object that groups multiple elements into a single unit.
and by the way, they use "C" in "Introduction to Collections". Why do they use "C" its not an Interface and not a beginning of sentence. Maybe they would like to show some idea? What about your case, what do you mean, Interface, some other idea? Who knows?
Maybe its a good idea to add some clarification for people who learn?

Re: About Question enthuware.ocpjp.v17.2.3729 :

Posted: Mon Nov 06, 2023 9:19 am
by admin
Since this discussion is linked to the question, other readers can also see it.

Even from the JavaDoc page for Collection that you quoted, "The root interface in the collection hierarchy.", Map is not a Collection because Map is not under that root interface.

So, as far as the explanation to this question is concerned, it is clear as well as correct.

Re: About Question enthuware.ocpjp.v17.2.3729 :

Posted: Sat Nov 11, 2023 5:21 pm
by Tester
I have found interesting question "Foundation Test 3 -> Q10":
Which is/are the root interface(s) for all collection related interfaces?

and the right answers:
Collection
Map

Could you please comment?

Re: About Question enthuware.ocpjp.v17.2.3729 :

Posted: Sat Nov 11, 2023 6:41 pm
by admin
It says "all collection related" but it would be better to write "collection framework related" or "collection API related".
Map is indeed part of the "collection framework".

Re: About Question enthuware.ocpjp.v17.2.3729 :

Posted: Sun Nov 12, 2023 9:10 am
by steinov
Which methods in the Spliterator interface should I know for the exam? The book I'm using (Sybex OCP 17 Study Guide) only mentions trySplit() forEachRemaining() and tryAdvance(). But this question also mentions estimateSize().

Btw, I think there is a small error in the explanation.
Therefore, the estimateSize() method will return an estimate but an exact number.
Should be
Therefore, the estimateSize() method will not return an estimate but an exact number.
Right?

Re: About Question enthuware.ocpjp.v17.2.3729 :

Posted: Sun Nov 12, 2023 11:32 am
by admin
1. Having a brief idea about trySplit, tryAdvance, forEachRemaining and estimateSize would be good enough for the exam.
2. Right. Fixed.