Swift

Swift

Test your Swift knowledge with free quizzes on MyCodeSkills covering core concepts.


  1. Which keyword is used to declare a constant in Swift?

    • var
    • let
    • const
    • constant
  2. What is the default value of an uninitialized optional variable in Swift?

    • nil
    • 0
    • undefined
    • empty string
  3. Which data type is used to represent true or false values in Swift?

    • Bool
    • Boolean
    • Int
    • Binary
  4. Which operator is used for string interpolation in Swift?

    • {}
    • ()
    • []
    • \()
  5. What is the correct syntax to declare an array in Swift?

    • let arr = []
    • let arr: [Int] = []
    • array arr = []
    • var arr = list()
  6. What is the primary difference between a struct and a class in Swift?

    • Classes are value types, structs are reference types
    • Structs are value types, classes are reference types
    • They are identical
    • Structs cannot have methods
  7. Which keyword is used to define a protocol in Swift?

    • protocol
    • interface
    • abstract
    • proto
  8. Which initializer is guaranteed to initialize all properties before use?

    • Designated initializer
    • Convenience initializer
    • Default initializer
    • Optional initializer
  9. Which access level makes an entity available only within the same source file?

    • private
    • internal
    • fileprivate
    • protected
  10. Which statement is used to match multiple cases in a switch statement?

    • case A, B:
    • case A and B:
    • case A or B:
    • case A|B:
  11. Which concurrency model was introduced in Swift 5.5?

    • Threads
    • Async/Await
    • Actors
    • Coroutines
  12. What is an actor in Swift?

    • A design pattern
    • A reference type that protects mutable state
    • A struct that runs async code
    • A UI element
  13. Which framework provides reactive programming in Swift?

    • ReactiveSwift
    • Combine
    • RxSwift
    • Streams
  14. Which SwiftUI property wrapper stores a value type in a view?

    • @State
    • @Binding
    • @ObservedObject
    • @Environment
  15. Which keyword suspends execution until a task completes?

    • await
    • async
    • pause
    • yield