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
1 Like
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
2 Likes
Related Questions
A single dimensional array has 50 elements, which of the following is the correct statement to initialize the last element to 100.
- x[51]=100
- x[48]=100
- x[49]=100
- x[50]=100
Write a Java program to store n numbers in an one dimensional array. Pass this array to a function number(int a[]). Display only those numbers whose sum of digit is prime.
The statement used to find the total number of Strings present in the string array String s[] is:
- s.length
- s.length()
- length(s)
- len(s)