Home » JAVA Programming » Data Structures » Question
  1. How is Arrays.asList() different than the standard way of initialising List?
    1. We cannot access the list returned using Arrays.asList()
    2. Arrays.asList() returns a fixed length list and doesn’t allow to add or remove elements
    3. Both are same
    4. Arrays.asList() throws compilation error
    5. None of these
Correct Option: B

List returned by Arrays.asList() is a fixed length list which doesn’t allow us to add or remove element from it.add() and remove() method will throw UnSupportedOperationException if used.



Your comments will be displayed only after manual approval.