wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

T3Quiz#2A09[GEN]

Total questions: 10

Worksheet time: 5mins

Name
Class
Date
1.

What can an array in Swift hold?

a)

Only integers

b)

Only characters

c)

Multiple types in one array

d)

Elements of the same type

2.

What is the index of the first element in a Swift array?

a)

1

b)

0

c)

-1

d)

Depends on array size

3.

What does myArray[3] refer to?

a)

The third element

b)

The fourth element

c)

The last element

d)

The first element

4.

Which part of the loop

for name in names {}

refers to the array?

a)

name

b)

in

c)

names

d)

for

5.

Which method adds an element to the end of an array?

a)

insert

b)

append

c)

push

d)

add

6.

How do you remove an item at index 2?

a)

array.pop(2)

b)

array.remove(at: 2)

c)

array.delete(2)

d)

remove(2)

7.

Which method inserts an element at a specific index?

a)

append

b)

push

c)

insert

d)

addAtIndex

8.

Choose the correct code to insert “Swift” at position 1

a)

array.append(1, "Swift")

b)

array.insert("Swift", at: 1)

c)

array[1] = "Swift"

d)

insert "Swift" in array[1]

9.

What does the for-in loop do in Swift?

a)

Defines an array

b)

Accesses and iterates each array element

c)

Removes array elements

d)

Declares a variable

10.

What will array.append("new") do?

a)

Insert “new” at index 0

b)

Replace last element with “new”

c)

Add “new” to end

d)

Remove “new” from array