java arrays Flashcards

(16 cards)

1
Q

a container object that holds a fixed number of values
of a single type.

A

array

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

The length of an array is established when the array is
____.

A

created

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

true or false: an array can store multiple values of different types.

A

false. it can store multiple values of the same type

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

true or false: array uses ZERO-based indexing( first elements at index 1)

A

false. first elements start at index 0

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

true or false: arrays have a fixed size, meaning it cannot grow or shrink dynamically.

A

true

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

elements in array are stored in _____

A

contiguous memory locations

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

Use ____ to access elements (arr[index]).

A

indexing

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

for-each format

A

for (int y : number){

System.out.println(number[y]); //print all element in the array

}

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

The ____ class is a resizable array, which can be found in
the java.util package.

A

ArrayList

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

difference between a built-in array and an ArrayList in Java

A

the size of an array cannot be modified, while elements in ArrayList can be.

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

to add elements

to the list, use the ____ method:

A

add()

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

To access an element in the ArrayList, use the ___ method and refer to the index number:

A

get()

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

To modify an element, use the ___ method and refer to the index number:

A

set()

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

– to remove an item, use the ____ method and refer to the index number

A

remove() ,

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

To remove all the elements in the ArrayList, use the
____ method:

A

clear()

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

to find out how many elements an ArrayList have, use the ____ method