Data Structures
- 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.
- Which of the below is not an implementation of List interface?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: B
SessionList is not an implementation of List interface. The others are concrete classes of List.
- What is the worst case complexity of accessing an element in ArrayList?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: D
ArrayList has O(1) complexity for accessing an element in ArrayList. O(n) is the complexity for accessing an element from LinkedList.
- 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 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.