What output will be produced by the code below?
var motto = "Bow ties are cool"
motto.replacingOccurrences(of: "Bow", with: "Neck")
print(motto)
Answer
When this code is executed, what value will num
have?
let num = UInt.min
Answer
When this code finishes executing, how many strings will the names
array contain?
let names = [String]()
names.append("Amy")
names.append("Clara")
names.append("Rory")
Answer
What output will be produced by the code below?
import Foundation
let number = 16.0
print("\(number) squared is \(number * number), and its square root is \(sqrt(number))")
Answer
What output will be produced by the code below?
class Starship {
var type: String
var age: Int
}
let serenity = Starship(type: "Firefly", age: 24)
print(serenity.type)
Answer
What output will be produced by the code below?
let names = ["Amy", "Clara"]
for i in 0 ... names.length {
print("Hello, \(names[i])!")
}
Answer
What output will be produced by the code below?
final class Dog {
func bark() {
print("Woof!")
}
}
class Corgi : Dog {
override func bark() {
print("Yip!")
}
}
let muttface = Corgi()
muttface.bark()
Answer
What output will be produced by the code below?
var i = 2
do {
print(i)
i *= 2
} while (i < 128)
Answer
How many bits are used to store an Int
?
What output will be produced by the code below?
func sayHello(to name: String) -> String {
return "Howdy, \(name)!"
}
print("\(sayHello(to: "Jayne"))")
Answer
What output will be produced by the code below?
struct Spaceship {
var name: String {
willSet {
print("I'm called \(newValue)!")
}
}
}
var serenity = Spaceship(name: "Serenity")
serenity.name = "TARDIS"
Answer
What output will be produced by the code below?
let oneMillion = 1_000_000
let oneThousand = oneMillion / 0_1_0_0_0
print(oneThousand)
Answer
What output will be produced by the code below?
import Foundation
let number = 16
print("\(number) squared is \(number * number), and its square root is \(sqrt(number))")
Answer
What output will be produced by the code below?
let names = ["Serenity", "Sulaco", "Enterprise", "Galactica"]
if let last = names.last {
print(last)
}
Answer
When this code is executed, what will be the value of the j
constant?
When this code is executed, what is the value of the swift
string?
import Foundation
let ns = NSString("Hello")
let swift = String(ns)
Answer
When this code is executed, what will the third
constant contain?
let first = ["Sulaco", "Nostromo"]
let second = ["X-Wing", "TIE Fighter"]
let third = first + second
Answer
Given the code below, what data type does i
have?
let i = 10.2
Answer
What output will be produced by the code below?
for i in 1...3 {
print(i)
}
Answer
What output will be produced by the code below?
let names = ["Serenity", "Sulaco", "Enterprise", "Galactica"]
for name in names where name.hasPrefix("S") {
print(name)
}
Answer
© 2017 QuizBucket.org