Arrays Flashcards

1
Q

What is an array used for?

A

A collection of variables of the same type organized in a way that can be easily manipulated.

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

Are arrays objects?

A

Yes

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

Array syntax

A

type arrayname[ ] = new type[size];

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

Base type

A

The element type of the array

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

Index

A

The location of an individual element in the array

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

Initializing an array

A

type arrayname[ ] = {val1, val2};

You can just initialize an array rather than using the new declaration.

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

What happens when you overrun the end of an array?

A

A run-time error

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

Multi dimensional array syntax

A

type arrayname [] [] = new type[size] [size];

Each dimension is placed in its own set of brackets.

Memory is specified for only the first (leftmost) dimension.

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

Array initialization for a 2D array

A

type arrayname[] [] = {
{Val, Val}
{Val, Val}
};

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

Alternative Array Declaration

A

type[] arrayname;

convenient when declaring multiple arrays on the same line.

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

arrayname1 = arrayname2;

Will the array contents be copied?

A

No, it will refer to the original array.

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

Array Length

How can it be used in iteration?

A

arrayname.length

It represents the number of elements an array can hold, not its actual contents.

Can be used to govern the number of iterations that take place.

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