Which is a valid way to declare and initialize an array in Java?
Answer options
A
int[] arr = new int[5];
B
int arr[] = new int[];
C
int[] arr = new int(-1);
D
int arr = new int[5];
Correct answer: int[] arr = new int[5];
Explanation
Quick AnswerThe correct answer is int[] arr = new int[5]; because it directly addresses the core logic of Java Programming.
This question has been retained as-is due to its unique context.