Arrays Flashcards
How do we access array elements?
The way to access array elements is using square brackets: [ ].
E.g. myArray[0]
What is wrong with this declaration?
String[ ] sA = new String[1] { "aaa"};
Array size cannot be given here as the array is being initialized in the declaration.
What are the initial values for an array of primitive types?
They are zero for numeric types and false for boolean.
T/F: Each dimension expression of an array is fully evaluated before the dimension expression to its right.
True.
What is the difference between A and B:
A:
int [ ] i, j;
B:
int i [ ], j;
A:
i and j are both an array of integers
B:
only i is an array of integers. j is simply an integer.
Is the following statement valid?
int [10] iA
No.
The size of an array is never specified on the left-hand side.