Which expression creates an int array with five elements?
int[5] newnew int[5]new int(5)array int 5new int[5] is the creation form the section uses: the keyword new, the element type, and the length inside square brackets.
Explanation
Declaring a variable such as int[] scores; only makes a variable that can hold an array reference. The array object itself comes from new, and the number in the square brackets fixes how many elements that object has.
- A is not correct: The pieces are in the wrong order;
newbegins the creation expression rather than trailing after the type and length. - C is not correct: Parentheses after a type are the constructor-call form seen in
new Student("Maya"); an array's length must sit inside square brackets instead. - D is not correct: This is not a creation expression at all. Nothing here is the keyword
new, and there is noint[]element type with a bracketed length.