201k views
2 votes
Which of the following creates an array of 25 components of the type int?

(i) int[] alpha = new[25];
(ii) int[] alpha = new int[25];

User Afonseca
by
5.1k points

1 Answer

2 votes

Answer:

(ii) int[] alpha = new int[25];

Step-by-step explanation:

In JAVA in order to create an array;

int name[];

name = new int[size];

can be written like above, however, to make it shorter can be written like below;

int[] name = new int[size];

Well, name is the array name you assign, int is the type of an array as integer and size you assign for an array, in that sense (ii) is the correct answer

(ii) int[] alpha = new int[25];

alpha is the name of an array

int is the type of array as an integer

25 is the size of an array

User Fritzmg
by
4.9k points