Questions, Tips and Tricks to clear iOS Interview Questions
Photo from Unsplash
I hope the interview series I published before helped you a lot to understand the iOS developer interview process and brush up with a few interesting topics. Now for a change lets try to test our skills with the below Questions:
var crew = ["Captain": "Malcolm", "Doctor": "Simon"]
crew = [:]
print(crew.count)
Options
let number = 5
switch number {
case 0..<5:
print("First group")
case 5...10:
print("Second group")
case 0...5:
print("Third group")
default:
print("Fourth group")
}
Options
let numbers = [1, 2, 3].map { [$0, $0] }
Options
var spaceships = Set<String>()
spaceships.insert("Serenity")
spaceships.insert("Enterprise")
spaceships.insert("TARDIS")
spaceships.insert("Serenity")
print(spaceships.count)
Options
let rounded: Int = round(10.5)
print("Rounding 10.5 makes \(rounded)")
Options
func greet(_ name: inout String) {
name = name.uppercased()
print("Greetings, \(name)!")
}
var name = "Mal"
greet(name)
print("Goodbye, \(name)!")
Options
let point = (556, 0)
switch point {
case (let x, 0):
print("X was \(x)")
case (0, let y):
print("Y was \(y)")
case let (x, y):
print("X was \(x) and Y was \(y)")
}
Options
var foo: Float = 32
var bar: Double = 32
Assuming no typecasting, which of the following statements is true?
Options
let people = [String](repeating: "Malkovitch", count: 2)
print(people)
Options
func sum(numbers: Int...) -> Int {
var result = 0
for number in numbers {
result += number
}
return result
}
let result = sum(numbers: [1, 2, 3, 4, 5])
Options
let crew = NSMutableDictionary()
crew.setValue("Kryten", forKey: "Mechanoid")
print(crew.count)
Options
enum MyError: Error {
case broken
case busted
case badgered
}
func willThrowAnError() {
throw MyError.busted
}
do {
try willThrowAnError()
} catch MyError.busted {
print("Code was busted!")
} catch {
print("Code just didn't work")
}
Options
let numbers = [1, 2, 3].flatMap { [$0, $0] }
Options
let possibleNumber = "1701"
let convertedNumber = Int(possibleNumber)
Options
let names = ["Pilot": "Wash", "Doctor": "Simon"]
let doctor = names["doctor"] ?? "Bones"
print(doctor)
Options
Thank you! will meet you in part 2 with a different set of questions 🚀
Swift By Sundell
Hacking With Swift
Raywenderlich
Swift Documentation by Apple
This is a free third party commenting service we are using for you, which needs you to sign in to post a comment, but the good bit is you can stay anonymous while commenting.