Search Header Logo

CSC400: Swift Arrays

Authored by Ayesha Abdullah

Computers

9th Grade

Used 2+ times

CSC400: Swift Arrays
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

8 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the syntax to declare an array in Swift?

let myArray = [Int]()

array myArray: [Int]

var myArray = []Int

var myArray: [Int]

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

How can you add a new element to the end of an array in Swift?

array.push(newElement)

array.append(newElement)

array.extend(newElement)

array.insert(newElement)

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What method is used to remove an element from an array in Swift?

delete(at:)

remove(at:)

extract(at:)

eliminate(at:)

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Provide an example of inserting an element at a specific index in an array in Swift.

numbers.add(10, at: 2)

numbers.insert(2, at: 10)

numbers.insert(10, at: 2)

numbers.insert(at: 2, 10)

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Explain the difference between append and insert methods in Swift arrays.

The insert method adds an element at the beginning of the array.

The append method adds an element at the end of the array, while the insert method adds an element at a specific index in the array.

The append method adds an element at the beginning of the array.

The append method adds an element at a specific index in the array.

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

How do you access the first element of an array in Swift?

arrayName.firstElement()

arrayName(1)

arrayName[0]

arrayName.getElement(0)

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What happens if you try to access an index in an array that is out of index number?

Array Overflow error

Invalid Index error

Memory Access Violation

Out of Bounds error

Access all questions and much more by creating a free account

Create resources

Host any resource

Get auto-graded reports

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

Already have an account?