Question: Which code snippet is valid?

  1. `ArrayList words = new ArrayList(){"Hello", "World"};`
  2. `ArrayList words = Arrays.asList("Hello", "World");`
  3. `ArrayList words = {"Hello", "World"};`
  4. `ArrayList words = new ArrayList<>(Arrays.asList("Hello", "World"));`

Answer: The correct answer of the above question is Option D:`ArrayList words = new ArrayList<>(Arrays.asList("Hello", "World"));`