Mid Term Study Arrays + Syntax Flashcards

1
Q

How to create an array of ints with 5 spots.
Then assign the index 3 a value of 5

A

int [] nums = new int [5];

nums[3] = 5;

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

What is the syntax for the FOR EACH loop?
iterate through int [] marks = {1, 2, 3, 4, 5}

A

for (int mark : marks){
}

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

When a reference variable isn’t pointing to an object (by holding the object’s address), it contains a _______

A

NULL value

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

When we create an array of ints and array of objects what does each element get initialized as?

int [] nums = new int[5]

Student [] students = new Student[5];

A

for array of ints they would all be initialized as 0

for array of objects they would be initialized as NULL

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