Set Interface. Flashcards

1
Q
  1. Does set contains insertion order and duplicate?
  2. What are all the Set interface?
  3. wt is the ds of set I ?
  4. If you want sorting in Set what will you do?
  5. Wt are the sub Interface we have in Set?
  6. Does linkedhash set follow insertion order?
A
  1. Duplicates not allowed and insertion order also not allowed.
  2. Hashset and Linked hashset
  3. Linked List is the DS
  4. I can use Sorted set (sub interface). for this
  5. We have Sorted set , navigable set , tree set .
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q
  1. How to convert linkedlist to linked hashset?
  2. Very Important , how do you convert a collection into Array?
  3. Very Important. if we convert toarray() incase if we have string value to in linked list what will happen ?
  4. What happen if we give

ll.add(sd);
Here, sd is a object name.

A
  1. Create linkedhashset object and pass the reference name in the print (parameters).
  2. By giving toarray();, but map can’t change
  3. It won’t print to make it print all obejcts we need to give
    Object ob = ll.toarray().
    Note: Because, why we giving object because Array accepts only homogenous objects .

and object is parent of all the String [] , char[] , int[] , and we can create our own array too like Laptop [] .
4. sd is a object name so it will print output as hashcode
To print a string , we need to give public void toString() method and give return “ABC”; Now it will print ABCas output.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q
  1. What is the use of toString() method?
A

1.The toString method is used to return a string representation of an object. If any object is printed, the toString() method is internally invoked by the java compiler.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Tree Set

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly