Swift LinkedIn Skill Assessment Answer

Here, We see Swift LinkedIn Skill Assessment Answer. This assessment test consists 15-20 MCQs to demonstrate your knowledge in your selected skills. MCQs comes from different topics – Classes and Structs, Closures and Functions, Control Flow, General, Types.

Swift Documentation ->

Swift LinkedIn Skill Assessment Answer

Swift LinkedIn Skill Assessment :-

Q1. What is this code an example of?

let val = (Double)6
  1. an error✔️
  2. typecasting
  3. assignment
  4. initialization

Q2. What is the error in this code?

let x = 5
guard x == 5 { return }
  1. The guard is missing the else.✔️
  2. Nothing is wrong.
  3. The guard is missing a then.
  4. The comparison is wrong.

Q3. What is the raw/underlying type of this enum?

enum Direction {
  case north, south, east, west
}
  1. There is none.✔️
  2. String
  3. Any
  4. Int

Q4. Why is dispatchGroup used in certain situations?

  1. It allows multiple synchronous or asynchronous operations to run on different queues.
  2. It allows track and control execution of multiple operations together.
  3. It allows operations to wait for each other as desired.
  4. all of these answers.✔️

Q5. What is this code an example of?

let val = 5
print("value is: \(val)")
  1. string interpolation✔️
  2. string compilation
  3. method chaining
  4. string concatenation

Q6. What are the contents of vals after this code is executed?

var vals = [10, 2]
vals.sort { (s1, s2) -> Bool in
  s1 > s2
}
  1. [10, 2]✔️
  2. [2, 10]
  3. nil
  4. This code contains an error

Q7. What does this code print?

typealias Thing = [String, Any]
var stuff: Thing
print(type(of: stuff))
  1. Dictionary<String, Any> (To print this than code in question has to be typealias Thing = [String: Any])
  2. Dictionary
  3. ERROR (If code in question is really like that.)✔️
  4. Thing

Q8. What is the value of y?

let x = ["1", "2"].dropFirst()
let y = x[0]
  1. This code contains an error✔️
  2. 1
  3. 2
  4. nil

Q9. What is the value of test in this code?

var test = 1 == 1
  1. TRUE✔️
  2. YES
  3. 1
  4. This code contains an error

Q10. What is the value of y?

var x: Int?
let y = x ?? 5
  1. 5✔️
  2. 0
  3. nil
  4. This code contains an error

Q11. What is the type of this function?

func add(a: Int, b: Int) -> Int { return a+b }
  1. Int
  2. (Int, Int) -> Int✔️
  3. Int<Optional>
  4. Functions don’t have types.

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

func myFunc(_ a: Int, b: Int) -> Int {
  return a + b
}
  1. myFunc(5, b: 6)✔️
  2. myFunc(5, 6)
  3. myFunc(a: 5, b: 6)
  4. myFunc(a, b)

Q13. The Codable protocol is _?

  1. a combination of Encodable and Decodable✔️
  2. not a true protocol <<<<—Possibly correct as it’s a typealias of Encodable and Decodable
  3. required of all classes
  4. automatically included in all classes

Q14. What is the type of value1 in this code?

let value1 = "\("test".count)"
  1. String✔️
  2. Int
  3. null
  4. test.count

Q15. When a function takes a closure as a parameter, when do you want to mark is as escaping?

  1. when it’s executed after the function returns✔️
  2. when it’s scope is undefined
  3. when is’s lazy loaded
  4. all of these answers

Q16. What’s wrong with this code?

class Person {
  var name: String
  var address: String
}
  1. Person has no initializers.✔️
  2. Person has no base class.
  3. var name is not formatted corrrectly.
  4. address is a keyword.

Q17. What is the value of names after this code is executed?

let names = ["Bear", "Joe", "Clark"]
names.map { (s) -> String in
  return s.uppercased()
}
  1. ["BEAR", "JOE", "CLARK"]
  2. ["B", "J", "C"]
  3. ["Bear", "Joe", "Clark"]✔️
  4. This code contains an error.

Q18. What describes this line of code?

let val = 5
  1. a constant named val of type Int✔️
  2. a variable named val of type item
  3. a constant named val of type Number
  4. a variable named val of type Int

Q19. What is the error in this code?

extension String {
  var firstLetter: Character = "c" {
    didSet {
      print("new value")
    }
  }
}
  1. Extensions can’t add properties.✔️ // although extensions technically can’t contain stored properties
  2. Nothing is wrong with it.
  3. didSet takes a parameter.
  4. c is not a character.

Q20. didSet and willSet are examples of _?

  1. property observers✔️
  2. key properties
  3. all of these answers
  4. newOld value calls

Q21. What is wrong with this code?

self.callback = {
  self.attempts += 1
  self.downloadFailed()
}
  1. Use of self inside the closure causes retain cycle.✔️
  2. You cannot assign a value to closure in this manner.
  3. You need to define the type of closure explicitly.
  4. There is nothing wrong with this code.

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

var vals = Set<String> = ["4", "5", "6"]
vals.insert("5")
  1. three✔️
  2. four
  3. eight
  4. This code contains an error.

Q23. How can you avoid a strong reference cycle in a closure?

  1. Use a capture list to set class instances of weak or unowned.✔️
  2. You can’t, there will always be a danger of strong reference cycles inside a closure.
  3. Initialize the closure as read-only.
  4. Declare the closure variable as lazy.

Q24. What is wrong with this code?

if let s = String.init("some string") {
  print(s)
}
  1. This String initializer does not return an optional.✔️
  2. String does not have an initializer that can take a String.
  3. = is not a comparison.
  4. Nothing is wrong with this code.

Q25. Which code snippet correctly creates a typealias closure?

  1. typealias CustomClosure: () -> ()✔️
  2. typealias CustomClosure { () -> () }
  3. typealias CustomClosure -> () -> ()
  4. typealias CustomClosure -> () {}

Q26. How do you reference class members from within a class?

  1. self✔️
  2. instance
  3. class
  4. this

Q27. All value types in Swift are _ under the hood?

  1. structs✔️
  2. classes
  3. optionals
  4. generics

Q28. What is the correct way to add a value to this array?

var strings = [1, 2, 3]
  1. all of these answers✔️
  2. strings.append(4)
  3. strings.insert(5, at: 1)
  4. strings += [5]

Q29. How many times will this loop be executed?

for i in 0...100 {
  print(i)
}
  1. 0
  2. 101✔️
  3. 99
  4. 100

Q30. What can AnyObject represent?

  1. an instance of any class
  2. an instance of function type
  3. all of these answers✔️
  4. an instance of an optional type

Q31. What does this code print?

typealias Thing = [String:Any]
var stuff : Thing
print(type(of:stuff))
  1. Dictionary
  2. ERROR
  3. Thing
  4. Dictionary<String, Any>✔️

Q32. What is the value of t after this code is executed?

let names = ["Larry", "Sven", "Bear"]
let t = names.enumerated().first().offset
  1. This code is invalid.✔️
  2. This code does not compile.✔️
  3. 0
  4. 1
  5. Larry

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

let vt = (name: "ABC", val: 5)
let test = vt.0
  1. ABC✔️
  2. 0
  3. 5
  4. name

Q33. What is the base class in this code?

class LSN : MMM {
}
  1. MMM✔️
  2. LSN
  3. There is no base class.
  4. This code is invalid.

Q34. What does this code print to the console?

var userLocation: String = "Home" {
  willSet(newValue) {
  print("About to set userLocation to \(newValue)...")
  }

  didSet {
  if userLocation != oldValue {
  print("userLocation updated with new value!")
  } else {
  print("userLocation already set to that value...")
  }
  }
 }

 userLocation = "Work"
  1. About to set userLocation to Work… userLocation updated with new value!✔️
  2. About to set userLocation to Work… userLocation already set to that value…
  3. About to set userLocation to Home… userLocation updated to new value!
  4. ERROR

Q35. What must a convenience initializer call?

  1. a base class convenience initializer
  2. either a designated or another convenience initializer
  3. a designated initializer✔️
  4. none of these answers

Q36. Which object allows you access to specify that a block of code runs in a background thread?

  1. DispatchQueue.visible
  2. DispatchQueue.global✔️
  3. errorExample need to be labeled as throws.
  4. DispatchQueue.background

Q37. What is the inferred type of x?

let x = ["a", "b", "c"]
  1. String[]
  2. Array<String>✔️
  3. Set<String>
  4. Array<Character>

Q38. What is the value of oThings after this code is executed?

let nThings: [Any] = [1, "2", "three"]
let oThings = nThings.reduce("") { "\($0)\($1)" }
  1. 11212three
  2. 115
  3. 12three✔️
  4. Nothing, this code is invalid.

Q39. How would you call a function that throws errors and also returns a value?

  1. !try
  2. try?✔️
  3. try!
  4. ?try

Q40. What is wrong with this code?

protocol TUI {
  func add(x1 : Int, x2 : Int) -> Int {
    return x1 + x2
  }
}
  1. Protocol functions cannot have return types.
  2. Protocol functions cannot have implementations.✔️
  3. Nothing is wrong with it.
  4. add is a reserved keyword.

Q41. In this code, what are wheels and doors examples of?

class Car {
  var wheels: Int = 4
  let doors = 4
}
  1. class members
  2. This code is invalid.
  3. class fields
  4. class properties✔️

Q42. How do you designated a failable initializer?

  1. You cannot
  2. deinit
  3. init?✔️
  4. init

Q43. What is printed when this code is executed?

let dbl = Double.init("5a")
print(dbl ?? ".asString()")
  1. five
  2. 5a
  3. .asString()✔️
  4. 5

Q44. In the function below, what are this and toThat examples of?

func add(this x: Int, toThat y: Int)->{}
  1. none of these answers
  2. local terms
  3. argument labels✔️
  4. parameters names

Q45. What is wrong with this code?

for (key, value) in [1: "one", 2: "two"]{
  print(key, value)
}
  1. The interaction source is invalid
  2. The interaction variable is invalid
  3. There is nothing wrong with this code✔️
  4. The comma in the print is misplaced

Q46. Which of these choices is associated with unit testing?

  1. XCTest
  2. all of these answers✔️
  3. @testable
  4. XCAssert

Q47. In the code below, what is width an example of?

class Square{
  var height: Int = 0
  var width : Int {
    return height
  }
}
  1. This code contains error
  2. a closure
  3. a computed property✔️
  4. lazy loading

Q48. What data type is this an example of?

let vals = ("val", 1)
  1. a dictionary
  2. a tuple✔️
  3. an optional
  4. This code contains error

Q49. What is wrong with this code?

var x = 5
x = 10.0
  1. You cannot assign a Double to a variable of type Int✔️
  2. x is undefined
  3. x is a constant
  4. x has no type

Q50. What will this code print to the console?

var items = ["a":1, "b":2, "c":"test"] as [String: Any]
items["c"] = nil
print(items["c"] as Any)
  1. Any
  2. test
  3. 1,2,3
  4. nil✔️

Q51. What is wrong with this code?

let val = 5.0 + 10
  1. There is nothing wrong with this code✔️
  2. val is a constant and cannot be changed
  3. 5.0 and 10 are different types
  4. There is no semicolon

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

struct Test{
  var score: Int
  var date: Date
}
  1. zero
  2. This code contains an error
  3. two✔️
  4. Structs do not have initializers

Q53. What prints to the console when executing this code?

let x = try? String.init("test")
print(x)
  1. nil
  2. Nothing – this code contains an error
  3. Optional("test")✔️
  4. test

Q54. How can you sort this array?

var vals = [1,2,3]
  1. vals.sort { $0 < $1 }
  2. vals.sort { (s1, s2) in s1 < s2 }
  3. vals.sort(by: <)
  4. all of these answers✔️

Q55. DispatchQueue.main.async takes a block that will be

  1. not executed
  2. executed in the main queue✔️
  3. none of these answers
  4. executed on the background thread

Q56. When is deinit called?

  1. When a class instance needs memory
  2. All of these answers✔️
  3. When the executable code is finished
  4. When a class instance is being removed from memory

Q57. How do you declare an optional String?

  1. String?✔️
  2. Optional[String]
  3. [String]?
  4. ?String

Q58. How many times this code will be executed? —OR— How many times will this loop be performed?

for i in ["0", "1"]{
  print(i)
}
  1. one
  2. two✔️
  3. three
  4. This code does not compile

Q59. What does this code print?

let names = ["Bear", "Tony", "Svante"]
print(names[1]+"Bear")
  1. 1Bear
  2. BearBear
  3. TonyBear✔️
  4. Nothing, this code is invalid

Q60. What is true of this code?

let name: String?
  1. name can hold only a string value.
  2. name can hold either a string or nil value.✔️
  3. Optional values cannot be let constants.
  4. Only non-empty string variables can be stored in name.

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

let i = 5
let val = i * 6.0
  1. This code is invalid.✔️
  2. 6
  3. 30
  4. 0

Q62. What does this code print?

enum Positions : Int {
  case first, second, third, other
}
print (Positions.other.rawValue)
  1. 3✔️
  2. 0
  3. other
  4. nil

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

"t".forEach { (char) in
    print(char)
}
  1. nil
  2. Nothing, since the code contains an error
  3. t✔️
  4. zero

Q64. What prints when this code is executed?

let s1 = ["1", "2", "3"]
    .filter { $0 > "0" }
    .sorted { $0 > $1 }
print(s1)
  1. []
  2. ["3", "2", "1"]✔️
  3. [321]
  4. ["1", "2", "3"]

Q65. What enumeration feature allows them to store case-specific data?

(Question does not make that much sense though. )

  1. associated values✔️
  2. integral values
  3. raw values
  4. custom values

Q66. In the code below, AOM must be a(n) _?

class AmP : MMM, AOM {
  }
  1. class
  2. protocol✔️
  3. enumeration
  4. struct

LinkedIn Swift Quiz Answers, LinkedIn Swift Assessment Answers, Swift LinkedIn Quiz Answers, Swift Assessment LinkedIn Answers, LinkedIn Skill Quiz Answers Swift, LinkedIn Swift Quiz, Swift LinkedIn Quiz, LinkedIn Quiz Answers Swift, LinkedIn Swift Assessment Quiz Answers, LinkedIn Skill Assessment Swift Answers, Swift LinkedIn Quiz, LinkedIn Swift Assessment Test Answers, LinkedIn Swift Test Answers, LinkedIn Swift Skill Assessment Answers, LinkedIn Skill Assessment Answers Swift, Swift LinkedIn Assessment Answers, LinkedIn Swift Assessment Answers, Swift LinkedIn Assessment Answers, Answers to LinkedIn Quizzes, LinkedIn Skill Assessment Answers GitHub, LinkedIn Assessment Test Answers, LinkedIn Skill Assessments Answers, Swift LinkedIn Skill Assessment Answer, Swift LinkedIn Skill Assessment Answer, Swift LinkedIn Skill Assessment Answer, LinkedIn assessment answers, LinkedIn skill assessment answers, LinkedIn assessments, LinkedIn skill assessment, LinkedIn assessment answers 2021, LinkedIn assessment answers GitHub, LinkedIn assessment quiz answers

No post found!

Leave a Comment

Your email address will not be published.