Computer Applications

Which of the following is a valid way to declare and initialize an integer array to store the ages of 50 students?

Java Arrays

2 Likes

Answer

int age[] = new int[50];

Reason — In Java, arrays are declared and initialized using the following syntax:

dataType arrayName[] = new dataType[size];

Here, int age[] = new int[50]; correctly declares an array of size 50 to store integer values.

Answered By

1 Like


Related Questions