When we write num[100] = 99.
How many elements can be stored inside the array variable num ?
Select one:
The statement gives no clue about the number of elements can be stored
100
99
Infinite number of elements
Answers
Explanation:
Among the various options given in question statement the correct option is the third one.
A multidimensional array of dimension N is a collection of N-1 dimensions. For example a 4 dimensional array is a collection of 3 dimensional arrays. An multidimensional array or a single dimensional array can contain pointer elements
Answer:
import java.util.*;
public class MyClass
{
public static void main(String args[])
{
Scanner Sc = new Scanner(System.in);
int num[] = new int[101];
num[100] = 99;
System.out.println("Length of array : " + num.length);
System.out.println("100th element : " + num[100]);
}
}
If we consider the above example, then, in that case, the number of elements in the array is 101, and as the indexing starts from 0 to N-1, so, the index of the last element is 100 and we have stored 99 at that index.
So, the output is:
Length of array : 101
100th element : 99