You are currently viewing swift linkedin assessment answers
swift linkedin assessment answers_theanswershome

swift linkedin assessment answers

1. What is the value of val after this code is executed?

let i = 5
let val = i * 6.0

  • 6
  • 30
  • 0
  • This code is invalid

2. What data type is this an example of?

let vals = ("val", 1)

  • a dictionary
  • an optional
  • None, this code contains an error.
  • a tuple

3. What is wrong with this code?

let val = 5.0 + 10

  • val is a constant and cannot be changed.
  • 5.0 and 10 are different types.
  • There is nothing wrong with this code.
  • There is no semicolon.

4. How many parameters does the initializer for Test have?

struct Test {
var score: Int
var date: Date
}

  • This code contains an error.
  • zero
  • Structs do not have initializers.
  • two

5. How many values does vals have after this code is executed?

var vals: Set<String> = ["4", "5", "6"]
vals.insert ("5")

  • eight
  • three
  • four
  • This code contains an error.

6. What is the return type of this function?

func printMe(returnMe : String) -> Int

  • String
  • Void
  • func
  • Int

7. What is the correct way to call this function?

func myFunc(_ a : Int, b: Int) -> Int {
return a + b
}

  • myFunc (5, 6)
  • myFunc (5, b: 6)
  • myFunc(a: 5, b: 6)
  • myFunc(a, b)

8. How many times is this loop executed?

for i in 1..<5 {
print(i)
}

  • five
  • zero
  • three
  • four

9. The Codable protocol is _____.

  • not a true protocol
  • automatically included in all classes
  • required of all classes
  • a combination of Encodable and Decodable

10. How many times will this loop be performed?

for i in ["0", "1"] {
print(i)
}

  • two
  • one
  • None, this code is invalid
  • three

11. What must a convenience initializer call?

  • either a designated or another convenience initializer
  • none of these answers
  • a designated initializer
  • a base class convenience initializer

12. What is printed to the console when this code is executed?

"t".forEach { (char) in
print(char)
}

  • t
  • Nothing, since the code contains an error.
  • nil
  • zero

13. What is the value of test after this code executes?

let vt = (name: "ABC", val: 5)
let test = vt.0

  • 0
  • ABC
  • name
  • 5

14. When is deinit called?

  • when a class instance is being removed from memory
  • when a class instance needs memorv
  • all of these answers
  • when the executable code is finished

15. How do you declare an optional string?

  • [String]?
  • ?String
  • Optional[String]
  • String?

Leave a Reply