Question: Could someone please help with some Swift programming questions? Question 11 A Swift function can return more than one value by returning a tuple. True

Could someone please help with some Swift programming questions?

Question 11

A Swift function can return more than one value by returning a tuple.

True
False

Question 12

Given the following Swift function, what is the argument label for the second parameter?

func find(pattern: String, in data: Data)

pattern
in
data
String
Data

Question 13

Given the following Swift function:

func find(pattern: String, in info: String) -> Int? { // code }

Which of the following is the correct way to call the function?

let position = find(pattern: "Sally", in: "People talked with Sally in the park.")
let position = find(pattern: "Sally", info: "People talked with Sally in the park.")
let position = find(pattern: "Sally", in info: "People talked with Sally in the park.")
let position = find("Sally", "People talked with Sally in the park.")

Question 14

Given the following Swift function:

func find(pattern: String, in info: String) -> Int? { // code }

What name is used to access the second parameter's value from within the function?

pattern
in
info
String

Question 15

If an _ is used as an argument label when declaring a Swift function, then no argument label is to be specified when calling the function.

True
False

Question 16

Swift does not allow default values to be specified for function parameters.

True
False

Question 17

The following line of Swift code appears in a source file.

var age: Int?

What is the purpose of the ? after Int in the line above?

Tags the variable to be reviewed later.
Unwraps the type.
Makes the variable changeable to another value.
Makes the Int an optional Int.

Question 18

A variable declared as an optional type cannot be set to nil.

True
False

Question 19

What does declaring a variable with an optional type allow?

Changing the type of the variable after it is declared.
Getting the memory address of the variable.
Saving the variable's value to storage.
Setting the variable to no value.

Question 20

Which of the following is used to represent a valueless state in Swift?

_
""
0
\0
nil

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!