What is one difference between a List and an Array?
A few!
A List can change size, while an Array's size cannot change.
A List can Add items dynamically.
An Array is instantiated with square bracket notation.
Oops!
Check
Okay!
Check
heart
Other team wins 20 points!
Oops!
fairy
Take points!
5
10
15
20
25
fairy
Take points!
5
10
15
20
25
thief
Give points!
5
10
15
20
25
15
Will this code work?
YES! It properly creates a new List of integers, adds two values to it, and prints the value at index 1 to the console.
Oops!
Check
Okay!
Check
boom
Lose 50 points!
Oops!
gold
Win 50 points!
Okay!
shark
Other team loses 25 points!
Okay!
thief
Give points!
5
10
15
20
25
20
What will be printed to the console?
3! There are three total elements added to the List.
Oops!
Check
Okay!
Check
10
Will this code work?
YES! It properly creates a new List of integers and adds a value to it.
Oops!
Check
Okay!
Check
15
What is the index of the first element in a List?
0!
Oops!
Check
Okay!
Check
seesaw
Swap points!
Oops!
seesaw
Swap points!
Okay!
shark
Other team loses 5 points!
Okay!
baam
Lose 10 points!
Oops!
10
Will this code work?
NO! The myList variable is never initialized.
Oops!
Check
Okay!
Check
10
Will this code work?
NO! It is not possible to add an integer to a list of strings.
Oops!
Check
Okay!
Check
trap
No points!
Oops!
gift
Win 25 points!
Okay!
gift
Win 10 points!
Okay!
banana
Go to last place!
Oops!
25
What will be printed to the console?
40! After adding four elements to the List, the program loops through and calculates the sum of all the values (multiplied by 10).
Oops!
Check
Okay!
Check
20
What will be printed to the console?
6! It first gets the value of the List at index 0 (which is 1), and then adds 5 to it.
Oops!
Check
Okay!
Check
15
Will this code work?
NO! The index (2) is out of bounds, because there are only two elements in the List (at index 0 and index 1).