+11

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.

2/22/2019 4:09:47 PM

FirstSoloKiller

+27

✔️Set contains only unique values. ✔️HasSet does not retain order. (U can see the answer/explanation in the quiz comment also. But u should always try to solve it yourself first.)

+10

FirstSoloKiller good to see you asking means of question but I just give you an suggestion if you at beginning level of learning Java or any languages first try to make code on concepts. I can relate At first stage it's really hard for you but you can try again and again as you code all this concept you will never forgot any logic your answer are already given by Serena it's just an suggestion to improve your coding path and skills because as when I'm on my initial path way this approach is very helpful because in interviews or any other compition the most conceptual implementation is required so you need to implement your mention concept like in this question and for that it's good to start from now😉

+6

+5

3 and 4

+2

+1

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:

+1

option 3 & 4