Arrays Flashcards

1
Q

toString method

A

displays elements in array as a string saves having to iterate in a loop

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

what type are arrays

A

arrays are objects so they are reference types

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

position of an element is called

A

index or subscript

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

What is different about using a for each instead of a for loop

A

the for each only lets you access the elements, not modify

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

accessing an array program

A

a program refers to any of the the elements in the array with an array access expression

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

where do arrays store length

A

in a length instance variable. accessed using array.length

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

default values within arrays

A

if the element is
primitive - 0
boolean - false
reference - null.

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

getting the length of a datatype

A

for arrays - .length this is an instance variable. this is because the length of an array cannot be altered, so it can be stored in a variable
for Strings - .length() this is a method of the string class because the length of a string can change so it must be recalculated if it is modified. BUT remember Strings can be stored inside of arrays

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