Arrays Flashcards

1
Q

How do we access array elements?

A

The way to access array elements is using square brackets: [ ].

E.g. myArray[0]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is wrong with this declaration?

String[ ] sA = new String[1] { "aaa"};
A

Array size cannot be given here as the array is being initialized in the declaration.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What are the initial values for an array of primitive types?

A

They are zero for numeric types and false for boolean.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

T/F: Each dimension expression of an array is fully evaluated before the dimension expression to its right.

A

True.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is the difference between A and B:

A:

int [ ] i, j;

B:

int i [ ], j;

A

A:

i and j are both an array of integers

B:

only i is an array of integers. j is simply an integer.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Is the following statement valid?

int [10] iA

A

No.

The size of an array is never specified on the left-hand side.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly