Computer Applications
Which of the following is the correct usage?
- int a[-40]
- int a[40]
- float a[0 - 40]
- None
Answer
None
Reason — In Java, an array is created using the new keyword, and its size is specified only at the time of creation, for example:int[] a = new int[40];
Statements like int a[40]; follow C/C++ syntax and are not valid in Java.
Also, an array size cannot be negative.
Therefore, none of the given statements is a correct array declaration in Java.
Related Questions
Which element is represented by a[10]?
- 10th
- 9th
- 11th
- None
Cell numbers of a dimensional array are also known as:
- packets
- blocks
- subscripts
- compartments
A dimensional array is also known as:
- subscripted variable
- actual variable
- compound variable
- none
An array element can be accessed through:
- dots
- element name
- index number
- none