Select the valid statement to declare and initialize an array.

Java MCQ: Select the valid statement to declare and initialize an array.

a) int[] arr = new int[5];
b) int arr[] = new int[5];
c) int arr[] = {1, 2, 3, 4, 5};
d) All of the above

Answer:

d) All of the above

Explanation:

All the provided statements are valid ways to declare and initialize an array in Java. You can create an array with a specified size or directly initialize it with values.

Reference links:

https://www.rameshfadatare.com/learn-java-programming/
https://www.javaguides.net/p/java-tutorial-learn-java-programming.html

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top