+ 8
What is the answer?
Which two of the following statements are true? LinkedHashSet does not retain order. Set can contain duplicate values. HashSet does not retain order. Set contains only unique values.
7 Antworten
+ 6
Probably your first answer in a while ig🤔 Serena Yvonne
+ 5
3 and 4
+ 3
1) FALSE LinkedHashSet does not retain order.
2) FALSE Set can contain duplicate values.
3) TRUE HashSet does not retain order.
4) TRUE Set contains only unique values.
1) FALSE LinkedHashSet does not retain order.
LinkedHashSet is also an implementation of Set interface, it is similar to the HashSet and TreeSet except the below mentioned differences: HashSet doesn't maintain any kind of order of its elements. TreeSet sorts the elements in ascending order. LinkedHashSet maintains the insertion order.
2) FALSE Set can contain duplicate values.
A Set is a Collection that cannot contain duplicate elements. It models the mathematical set abstraction. The Set interface contains only methods inherited from Collection and adds the restriction that duplicate elements are prohibited.
3) TRUE HashSet does not retain order.
A Set is a Collection that cannot contain duplicate elements. It models the mathematical set abstraction. The Set interface contains only methods inherited from Collection and adds the restriction that duplicate elements are prohibited.
4) TRUE Set contains only unique values.
HashSet is an unordered collection containing unique elements. It has the standard collection operations Add, Remove, Contains, but since it uses a hash-based implementation, these operations are O(1). ( As opposed to List for example, which is O(n) for Contains and Remove.)
HINT: Gotta love google:
+ 2
option 3 & 4
+ 1
3