Swift quiz and interview questions

Comprehensive Swift language quiz and questions from basic to advanced level that help you to review your Swift language knowledge and become the master of Swift language. Please read the following question carefully and select the correct anwser, you have to make your choice before going to the next question.

Recent added questions

  • What output will be produced by the code below?

    var motto = "Bow ties are cool"
    motto.replacingOccurrences(of: "Bow", with: "Neck")
    print(motto)
  • When this code is executed, what value will num have?

    let num = UInt.min
  • 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")
  • 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))")
  • 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)
  • What output will be produced by the code below?

    let names = ["Amy", "Clara"]
    for i in 0 ... names.length {
        print("Hello, \(names[i])!")
    }
  • 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()
  • What output will be produced by the code below?

    var i = 2
    do {
        print(i)
        i *= 2
    } while (i < 128)

View all Swift quiz questions

© 2017 QuizBucket.org