Question:

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

Show Hint

In Java, initialize arrays using curly braces: int[] array = {val1, val2, val3};
Updated On: Jul 14, 2025
  • int[] marks;
  • int[] marks = 60, 70, 90;
  • int[] marks = (60, 70, 90);
  • int[] marks = [60, 70, 90];
Hide Solution
collegedunia
Verified By Collegedunia

The Correct Option is B

Solution and Explanation

In Java, arrays are used to store multiple values of the same type in a single variable.
To declare and initialize an array, the correct syntax is: int[] marks = 60, 70, 90;
- Option (A) is only a declaration, not initialization.
- Option (C) is invalid because Java does not use parentheses for array initialization.
- Option (D) uses square brackets incorrectly — Java uses them for type declaration, not for initializing values.
Only option (B) correctly uses curly braces and assigns values to the array.
Was this answer helpful?
0
0

Questions Asked in CBSE CLASS XII exam

View More Questions