Logo

Swift Questions Set 6:

Quiz Mode

What data type is returned when a data type conversion can potentially fail?

1
2
3
4

Solution:

What is the exact opposite of opaque types?

1
2
3
4

Solution:

Which keyword is used to declare weak references or variables in Swift?

1
2
3
4

Solution:

What kind of initializer delegation is allowed for value types in Swift?

1
2
3
4

Solution:

Is it necessary to define the data types of the parameters in Swift closures?

1
2
3
4

Solution:

Which properties are used in Swift to get the minimum and maximum value of an integer type?

1
2
3
4

Solution:

What types of methods can be overridden in Swift?

1
2
3
4

Solution:

What will be the output of the following code?

func addTwoInts(_ a: Int, _ b: Int) -> Int {

  return a + b

}

var mathFunction: (Int, Int) -> Int = addTwoInts

print(mathFunction(3, 9))

1
2
3
4

Solution:

When does Swift use default initializers for classes?

1
2
3
4

Solution:

What will be the output of the following code?

func swapTwoInts(_ a: inout Int, _ b: inout Int) {

  let temporaryA = a

  a = b

  b = temporaryA

}

var someInt = 3

var anotherInt = 107

swapTwoInts(&someInt, &anotherInt)

print("someInt is now \(someInt), and anotherInt is now \(anotherInt)")

1
2
3
4

Solution: