Arrays Flashcards

1
Q

formula for reference for arrays

A

[ ] =

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

two ways to create an array

A

create and list the elements

create sufficient space`

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

how to create space eg. int array, name numbers, with 5 elements

A

int [] numbers = new int [5];

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

can you mix types in a list

A

no

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

how to find the number of elements in an array

A

.length

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

when an array is empty its called

A

a null array

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

what happens if we refer to an index that is outside of the array

A

ArrayIndexOutOfBoundsException

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

values of the indexes of an array

A

from 0 to array.length-1

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

if you change the contents of one array with multiple references does the array change for all the refernces

A

yes

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

ways to make a cpoy of an array

A

using a for loop to cpoy over each element
arraycopy function
copyOf function
clone function

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

layout for arraycopy

A

(source array, starting at element, destination array, starting at element, how many elements are being copied over

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

layout for copyOf

A

(copy from, length to be copied)

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

is the size of an array fixed

A

yes

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

to extend or shrink an array we musr

A

create a new array with our desired length and then copy over elements into that array

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

do we need to delete arrays if were no longer referencing them

A

no, java sends them to garbage automatically

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

how to create a 2d array

A

int [][] matrix = new int [x][y]

17
Q

how to access the 3rdelement in the 5th row of the aray

A

array [4][2]

18
Q

how to find number of rows in a 2d array

A

array.length

19
Q

how to find number of c`olumns in a 2d array

A

array[rowNumber].length

20
Q

can 2d arrays be jagged ie can rows have different numbers of elements

A

yes

21
Q

position in an array is also known as its

A

index

22
Q

arrays start counting from

A

0