Machine-translated by Google. Questions are authored in English.
Top

Discussion

What Collections.frequency counts - which of the following is true?

  • A.How many times the collection has been structurally modified.
  • B.How many buckets a hash-based collection is currently using.
  • C.How many elements of the collection are equal to the given object.
  • D.How many distinct values the collection contains.

Answer: C

Correct answer: How many elements of the collection are equal to the given object.

Collections.frequency(c, o) walks the collection and counts the elements equal to o, using equals - or an identity comparison when o is null. It is a linear scan and is chiefly useful on a List or other collection that permits duplicates, since in a Set the answer can only be zero or one.

No comment is present. Be the first to comment.
Loading…

Post your comment

Please log in or register to post a comment.