Swift - Sample Interview Question (Junior Level)

What will be shown in the console after calling the function quest04

enum MyError: ErrorType {
  case e1
  case e2
  case e3
}

func quest04() {
  do {
    try doStuff5()
    print("A")
  } catch {
    print("B")
  } catch MyError.e2{
    print("C")
  }
}

func doStuff5() throws -> String {
  print("D")
  print("E")
  throw MyError.e2
  return "F"
}

  1. D E B
  2. D E C
  3. D E B A
  4. D E C A
Tests in Swift for Juniors

Test Name Difficulty Time (minutes) No. of Questions
Swift Online Test for Juniors Swift Junior 20 10