+ 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.

22nd Feb 2019, 4:09 PM
FirstSoloKiller
FirstSoloKiller - avatar
7 Answers
+ 6
Probably your first answer in a while igđŸ€” Serena Yvonne
22nd Feb 2019, 5:38 PM
Nimit Sandeep Jhunjhunwala
Nimit Sandeep Jhunjhunwala - avatar
+ 5
3 and 4
23rd Feb 2019, 1:42 AM
Sonic
Sonic - avatar
+ 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:
23rd Feb 2019, 7:44 PM
Timothy Murphy
Timothy Murphy - avatar
+ 2
option 3 & 4
24th Feb 2019, 11:01 AM
Ayush Dixit
Ayush Dixit - avatar
+ 1
3
24th Feb 2019, 1:48 AM
John Asaolu
John Asaolu - avatar