WorksheetsT3Quiz#2A09[GEN]
Total questions: 10
Worksheet time: 5mins
What can an array in Swift hold?
Only integers
Only characters
Multiple types in one array
Elements of the same type
What is the index of the first element in a Swift array?
1
0
-1
Depends on array size
What does myArray[3] refer to?
The third element
The fourth element
The last element
The first element
Which part of the loop
for name in names {}
refers to the array?
name
in
names
for
Which method adds an element to the end of an array?
insert
append
push
add
How do you remove an item at index 2?
array.pop(2)
array.remove(at: 2)
array.delete(2)
remove(2)
Which method inserts an element at a specific index?
append
push
insert
addAtIndex
Choose the correct code to insert “Swift” at position 1
array.append(1, "Swift")
array.insert("Swift", at: 1)
array[1] = "Swift"
insert "Swift" in array[1]
What does the for-in loop do in Swift?
Defines an array
Accesses and iterates each array element
Removes array elements
Declares a variable
What will array.append("new") do?
Insert “new” at index 0
Replace last element with “new”
Add “new” to end
Remove “new” from array
