- What is the advantage of arrays in a programming language? (of Arrays Java Interview Questions)
Arrays avoid the declaration of a number of variables. With one array variable, number of values can be stored, using index numbers.
- What are the features of arrays in Java? (of Arrays Java Interview Questions)
Same rules of C/C++ can be applied mostly.
- Stores similar data types.
- Contiguous (continuous) memory is allocated for the elements.
- All the elements can be accessed with their index numbers where the first element added gets by default 0 index and the second element gets 1 and so on.
- Accessing elements with their index number is very fast (have greater performance).
- Java supports multi-dimensional arrays and Jagged (variable size) arrays.
- Once array is created, its size is fixed. That is, at runtime its size cannot be changed (when the programmer would like to add some more elements which he did not expect at the time of array creation).
- With arraycopy() method, copying of one array elements into another is easier.
- Arrays are predefined objects in Java. Array objects like other objects, support pass-by-value and pass-by-reference. Programs one one-dimensional and two-dimensional arrays are available.
Pass your comments and suggestions to improve the quality of this tutorial "Arrays Java Interview Questions".