Data Structures
- When an array is passed to a method, will the content of the array undergo changes with the actions carried within the function?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: C
If we make a copy of array before any changes to the array the content will not change. Else the content of the array will undergo changes.
- What is the default clone of HashSet?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: C
Default clone() method uses shallow copy. The internal elements are not cloned. A shallow copy only copies the reference object.
- Do we have get(Object o) method in HashSet.
-
View Hint View Answer Discuss in Forum
NA
Correct Option: C
get(Object o) method is useful when we want to compare objects based on the comparison of values. HashSet does not provide any way to compare objects. It just guarantees unique objects stored in the collection.
- What does Collections.emptySet() return?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: D
Immutable Set is useful in multithreaded environment. One does not need to declare generic type collection. It is inferred by the context of method call.
- What are the initial capacity and load factor of HashSet?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: B
We should not set the initial capacity too high and load factor too low if iteration performance is needed.