Home > iOS Programming > Quizzes > Swift Programming Quiz
Swift Programming Quiz
Fast practice, instant feedback. Timer auto-submits when time’s up.
Avg score: 11% Most missed: “What is the error in this code?”

Swift Programming  MCQs For LinkedIn Skill Assessments.

Swift Programming Quiz
Time left 00:00
25 Questions

1. didSet and willSet are examples of '\_'?
2. When a function takes a closure as a parameter, when do you want to mark is as escaping?
3. How can you sort this array?
swift
var vals = [1,2,3]
4. What is the correct way to add a value to this array?
swift
var strings = [1, 2, 3]
5. How can you avoid a strong reference cycle in a closure?
6. What data type is this an example of?
swift
let vals = ('val', 1)
7. What does this code print to the console?
swift
var userLocation: String = 'Home' {
willSet(newValue) {
print('About to set userLocation to \(newValue)...')
}
didSet {
if userLocation != oldValue {
print('userLocation updated with new value!')
} else {
print('userLocation already set to that value...')
}
}
}
userLocation = 'Work'
8. What can AnyObject represent?
9. What is the type of value1 in this code?
swift
let value1 = '\('test'.count)'
10. How many times this code will be executed? —OR— How many times will this loop be performed?
swift
for i in ['0', '1']{
print(i)
}
11. What is the value of y?
swift
let x = ['1', '2'].dropFirst()
let y = x[0]
12. What does this code print?
swift
enum Positions : Int {
case first, second, third, other
}
print (Positions.other.rawValue)
13. What is the raw/underlying type of this enum?
swift
enum Direction {
case north, south, east, west
}
14. Which of these choices is associated with unit testing?
15. DispatchQueue.main.async takes a block that will be
16. What is the type of this function?
swift
func add(a: Int, b: Int) -> Int { return a+b }
17. Why is dispatchGroup used in certain situations?
18. What is wrong with this code?
swift
if let s = String.init('some string') {
print(s)
}
19. What is wrong with this code?
swift
var x = 5
x = 10.0
20. All value types in Swift are '\_' under the hood?
21. Which object allows you access to specify that a block of code runs in a background thread?
22. What does this code print?
swift
typealias Thing = [String:Any]
var stuff: Thing
print(type(of: stuff))
23. What describes this line of code?
swift
let val = 5
24. In the code below, AOM must be a(n)?
swift
class AmP : MMM, AOM {
}
25. What is the type of 'vals' in this code?
swift
let vals = ['a', 1, 'Hi']