Final answer:
The correct options for initializing an array in Java explained.
Step-by-step explanation:
The correct way to initialize an array in Java is:
- int[] arr = new int[5];
- int[] arr = {1, 2, 3, 4, 5};
- int[] arr = new int[]{1, 2, 3, 4, 5};
The incorrect way to initialize an array is:
- int[] arr = new int[5]{1, 2, 3, 4, 5};
Option 4 is not valid because when using the new keyword to initialize an array, you cannot provide explicit values inside the square brackets.