Computer Applications
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
Java Arrays
5 Likes
Answer
number[5] is undefined
Reason — The valid subscripts of an array of size N are from 0 to N - 1. Thus, subscripts of array number will be from 0 to 4 (5 - 1).
Answered By
1 Like
Related Questions
Total number of elements in array C[5][3][2] are …………… .
- 10
- 20
- 30
- 50
Which of the following statements are valid array declaration ?
- int number( );
- float average[ ];
- double[ ] marks;
- counter int[ ];
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);
Given that
int A[ ] = {35, 26, 19, 76, 58};
What will be value contained in A[3] ?- 35
- 26
- 19
- 76
- 58