Computer Applications
Which of the following statements are valid array declaration ?
- int number( );
- float average[ ];
- double[ ] marks;
- counter int[ ];
Java Arrays
12 Likes
Answer
float average[ ];
double[ ] marks;
Reason — The statements float average[ ]; and double[ ] marks; are valid as they follow the syntax for declaration of an array.
int number( ); uses small brackets () instead of square brackets []. The correct statement will be int number[];.
counter int[ ]; has exchanged the place of data type and array variable. The correct statement will be int counter[];
Answered By
4 Likes
Related Questions
Total size of array B[10][5] of int type is …………… .
- 50 bytes
- 15 bytes
- 100 bytes
- 200 bytes
Total number of elements in array C[5][3][2] are …………… .
- 10
- 20
- 30
- 50
Consider the following code
int number[ ] = new int[5];After execution of this statement, which of the following are True ?
- number[0] is undefined
- number[5] is undefined
- number[2] is 0
- number.length is 5
Which of the following contain error ?
- int x[ ] = int[10];
- int[ ] y = new int[5];
- float d[ ] = {1, 2, 3};
- x = y = new int[10];
- int a[ ] = {1, 2}; int b[ ]; b = a;
- int i = new int(10);