Swift quiz questions

Swift interview questions

  • 1.

    Which keyword in the context of a Switch statement is required to force the execution of a subsequent case?

    1. Fallthrough

    2. Continue

    3. Release

    4. DropEnd

    Answer
  • 2.

    When declaring an enumeration, multiple member values can appear on a single line, separated by which punctuation mark?

    1. Semi-colon

    2. Colon

    3. Comma

    4. Question Mark

    Answer
  • 3.

    What would be used for safe casting and to return nil if failed?

    1.  as?

    2. as!

    3. !as?

    4.  !as!

    Answer
  • 4.

    Which of the following statements could be used to determine if a given variable is of String type?

    1.  if unknownVariable is String { }

    2. if unkownVariable: String { }

    3. if unkownVariable = String() { }

    4. if unkownVariable <> String[] { }

    Answer
  • 5.

    All Swift classes must inherit from which root class?

    1. Not Required

    2. NSObject

    3. NSRootObject

    4. @ObjC

    Answer
  • 6.

    Which one of the below functions definitions is wrong considering Swift language?

    1. func haveChar(#string: String, character: Character) -> (Bool)

    2. func mean(numbers: Double...) -> Double

    3. func minMax(array: [Int]) -> (min: Int, max: Int)?

    4. func minMax(array: [Int]) -> (min: Int?, max: Int?)

    Answer
  • 7.

    Which of the following structures has both computed and stored properties?

    1. struct Rect { var origin = CGPointZero var center: CGPoint { get { // } set { // } } }

    2. struct Rect { var center: CGPoint { get { // } set { // } } }

    3. struct Rect { let origin = CGPointZero }

    4. struct Rect { var origin = CGPointZero var center: CGPointMake(0,0) }

    Answer

© 2017 QuizBucket.org