Multiple choice technology programming languages

How can you sort a ArrayList?

  1. By creating an implementation of the java.lang.Comparable interface.

  2. java.util.Collections.sort()

  3. java.utils.Arrays.sort()

  4. By creating an implementation of the java.lang.Comparator interface.

Reveal answer Fill a bubble to check yourself
A,B,D Correct answer
Explanation

ArrayList can be sorted by implementing Comparable (natural ordering for the object type), using Collections.sort() utility method, or by providing a custom Comparator for custom ordering logic. The option C references java.utils.Arrays.sort() which has a typo (should be java.util.Arrays) and works on arrays not ArrayLists directly.