The LinkedIn Skill Assessments feature allows you to demonstrate your knowledge of the skills you’ve added on your profile. Job posters on LinkedIn can also add Skill Assessments as part of the job application process. This allows job posters to more efficiently and accurately verify the crucial skills a candidate should have for a role.
The topics in the Swift assessment include:
- Types
- Classes and Structs
- General
- Closures and Functions
- Control Flow
- Optionals
- Threading
- Protocols
- Extensions
- Unit Testing
Question Format
Multiple Choice
Language
English
Table of Content
- 1 LinkedIn Swift Skill Assessment Answers
- 1.1 What is this code an example of?
- 1.2 What is the error in this code?
- 1.3 What is the raw/underlying type of this enum?
- 1.4 Why is dispatchGroup used in certain situations?
- 1.5 What is this code an example of?
- 1.6 What are the contents of vals after this code is executed?
- 1.7 What does this code print?
- 1.8 What is the value of y?
- 1.9 What is the value of test in this code?
- 1.10 What is the value of y?
- 1.11 What is the type of this function?
- 1.12 What is the correct way to call this function?
- 1.13 The Codable protocol is _?
- 1.14 What is the type of value1 in this code?
- 1.15 When a function takes a closure as a parameter, when do you want to mark is as escaping?
- 1.16 What’s wrong with this code?
- 1.17 What is the value of names after this code is executed?
- 1.18 What describes this line of code?
- 1.19 What is the error in this code?
- 1.20 didSet and willSet are examples of _?
- 1.21 What is wrong with this code?
- 1.22 How many values does vals have after this code is executed?
- 1.23 How can you avoid a strong reference cycle in a closure?
- 1.24 What is wrong with this code?
- 1.25 Which code snippet correctly creates a typealias closure?
- 1.26 How do you reference class members from within a class?
- 1.27 All value types in Swift are _ under the hood?
- 1.28 What is the correct way to add a value to this array?
- 1.29 How many times will this loop be executed?
- 1.30 What can AnyObject represent?
- 1.31 What does this code print?
- 1.32 What is the value of t after this code is executed?
- 1.33 What is the value of test after this code executes?
- 1.34 What is the base class in this code?
- 1.35 What does this code print to the console?
- 1.36 What must a convenience initializer call?
- 1.37 Which object allows you access to specify that a block of code runs in a background thread?
- 1.38 What is the inferred type of x?
- 1.39 What is the value of oThings after this code is executed?
- 1.40 How would you call a function that throws errors and also returns a value?
- 1.41 What is wrong with this code?
- 1.42 In this code, what are wheels and doors examples of?
- 1.43 How do you designated a failable initializer?
- 1.44 What is printed when this code is executed?
- 1.45 In the function below, what are this and toThat examples of?
- 1.46 What is wrong with this code?
- 1.47 Which of these choices is associated with unit testing?
- 1.48 In the code below, what is width an example of?
- 1.49 What data type is this an example of?
- 1.50 What is wrong with this code?
- 1.51 What will this code print to the console?
- 1.52 What is wrong with this code?
- 1.53 How many parameters does the initializer for Test have?
- 1.54 What prints to the console when executing this code?
- 1.55 How can you sort this array?
- 1.56 DispatchQueue.main.async takes a block that will be
- 1.57 When is deinit called?
- 1.58 How do you declare an optional String?
- 1.59 How many times this code will be executed? —OR— How many times will this loop be performed?
- 1.60 What does this code print?
- 1.61 What is true of this code?
- 1.62 What is the value of val after this code is executed?
- 1.63 What does this code print?
- 1.64 What is printed to the console when this code is executed?
- 1.65 What prints when this code is executed?
- 1.66 What enumeration feature allows them to store case-specific data?
- 1.67 In the code below, AOM must be a(n) _?
- 1.68 What is the value of numbers in the code below?
- 1.69 What is the type of vals in this code?
- 1.70 How can you extract val to x in tuple vt
- 1.71 What is the type of x: let x = try?
- 1.72 How many times is this loop executed?
- 1.73 How many values does vals have after this code is executed?
LinkedIn Swift Skill Assessment Answers
What is this code an example of?
let val = (Double)6
- an error
- typecasting
- assignment
- initialization
What is the error in this code?
let x = 5
guard x == 5 { return }
- The guard is missing the else.
- Nothing is wrong.
- The guard is missing a then.
- The comparison is wrong.
What is the raw/underlying type of this enum?
enum Direction {
case north, south, east, west
}
- There is none.
- String
- Any
- Int
Why is dispatchGroup used in certain situations?
- It allows multiple synchronous or asynchronous operations to run on different queues.
- It allows track and control execution of multiple operations together.
- It allows operations to wait for each other as desired.
- all of these answers.
What is this code an example of?
let val = 5
print(“value is: \(val)”)
- string interpolation
- string compilation
- method chaining
- string concatenation
What are the contents of vals after this code is executed?
var vals = [10, 2]
vals.sort { (s1, s2) -> Bool in
s1 > s2
}
- [10, 2]
- [2, 10]
- nil
- This code contains an error
What does this code print?
typealias Thing = [String, Any]
var stuff: Thing
print(type(of: stuff))
- Dictionary<String, Any> (To print this than code in question has to be typealias Thing = [String: Any])
- Dictionary
- ERROR (If code in question is really like that.)
- Thing
What is the value of y?
let x = [“1”, “2”].dropFirst()
let y = x[0]
- This code contains an error
- 1
- 2
- nil
What is the value of test in this code?
var test = 1 == 1
- TRUE
- YES
- 1
- This code contains an error
What is the value of y?
var x: Int?
let y = x ?? 5
- 5
- 0
- nil
- This code contains an error
What is the type of this function?
func add(a: Int, b: Int) -> Int { return a+b }
- Int
- (Int, Int) -> Int
- Int<Optional>
- Functions don’t have types.
What is the correct way to call this function?
func myFunc(_ a: Int, b: Int) -> Int {
return a + b
}
- myFunc(5, b: 6)
- myFunc(5, 6)
- myFunc(a: 5, b: 6)
- myFunc(a, b)
The Codable protocol is _?
- a combination of Encodable and Decodable
- not a true protocol
- required of all classes
- automatically included in all classes
What is the type of value1 in this code?
let value1 = “\(“test”.count)”
- String
- Int
- null
- test.count
When a function takes a closure as a parameter, when do you want to mark is as escaping?
- when it’s executed after the function returns
- when it’s scope is undefined
- when is’s lazy loaded
- all of these answers
What’s wrong with this code?
class Person {
var name: String
var address: String
}
- Person has no initializers.
- Person has no base class.
- var name is not formatted corrrectly.
- address is a keyword.
What is the value of names after this code is executed?
let names = [“Bear”, “Joe”, “Clark”]
names.map { (s) -> String in
return s.uppercased()
}
- [“BEAR”, “JOE”, “CLARK”]
- [“B”, “J”, “C”]
- [“Bear”, “Joe”, “Clark”]
- This code contains an error.
What describes this line of code?
let val = 5
- a constant named val of type Int
- a variable named val of type item
- a constant named val of type Number
- a variable named val of type Int
What is the error in this code?
extension String {
var firstLetter: Character = “c” {
didSet {
print(“new value”)
}
}
}
- Extensions can’t add properties.
- Nothing is wrong with it.
- didSet takes a parameter.
- c is not a character.
didSet and willSet are examples of _?
- property observers
- key properties
- all of these answers
- newOld value calls
What is wrong with this code?
self.callback = {
self.attempts += 1
self.downloadFailed()
}
- Use of self inside the closure causes retain cycle.
- You cannot assign a value to closure in this manner.
- You need to define the type of closure explicitly.
- There is nothing wrong with this code.
How many values does vals have after this code is executed?
var vals = Set<String> = [“4”, “5”, “6”]
vals.insert(“5”)
- three
- four
- eight
- This code contains an error.
How can you avoid a strong reference cycle in a closure?
- Use a capture list to set class instances of weak or unowned.
- You can’t, there will always be a danger of strong reference cycles inside a closure.
- Initialize the closure as read-only.
- Declare the closure variable as lazy.
What is wrong with this code?
if let s = String.init(“some string”) {
print(s)
}
- This String initializer does not return an optional.
- String does not have an initializer that can take a String.
- = is not a comparison.
- Nothing is wrong with this code.
Which code snippet correctly creates a typealias closure?
- typealias CustomClosure: () -> ()
- typealias CustomClosure { () -> () }
- typealias CustomClosure -> () -> ()
- typealias CustomClosure -> () {}
How do you reference class members from within a class?
- self
- instance
- class
- this
All value types in Swift are _ under the hood?
- structs
- classes
- optionals
- generics
What is the correct way to add a value to this array?
var strings = [1, 2, 3]
- all of these answers
- strings.append(4)
- strings.insert(5, at: 1)
- strings += [5]
How many times will this loop be executed?
for i in 0…100 {
print(i)
}
- 0
- 101
- 99
- 100
What can AnyObject represent?
- an instance of any class
- an instance of function type
- all of these answers
- an instance of an optional type
What does this code print?
typealias Thing = [String:Any]
var stuff : Thing
print(type(of:stuff))
- Dictionary
- ERROR
- Thing
- Dictionary<String, Any>
What is the value of t after this code is executed?
let names = [“Larry”, “Sven”, “Bear”]
let t = names.enumerated().first().offset
- This code is invalid.
- This code does not compile.
- 0
- 1
- Larry
What is the value of test after this code executes?
let vt = (name: “ABC”, val: 5)
let test = vt.0
- ABC
- 0
- 5
- name
What is the base class in this code?
class LSN : MMM {
}
- MMM
- LSN
- There is no base class.
- This code is invalid.
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”
- About to set userLocation to Work… userLocation updated with new value!
- About to set userLocation to Work… userLocation already set to that value…
- About to set userLocation to Home… userLocation updated to new value!
- ERROR
What must a convenience initializer call?
- a base class convenience initializer
- either a designated or another convenience initializer
- a designated initializer
- none of these answers
Which object allows you access to specify that a block of code runs in a background thread?
- DispatchQueue.visible
- DispatchQueue.global
- errorExample need to be labeled as throws.
- DispatchQueue.background
What is the inferred type of x?
let x = [“a”, “b”, “c”]
- String[]
- Array<String>
- Set<String>
- Array<Character>
What is the value of oThings after this code is executed?
let nThings: [Any] = [1, “2”, “three”]
let oThings = nThings.reduce(“”) { “\($0)\($1)” }
- 11212three
- 115
- 12three
- Nothing, this code is invalid.
How would you call a function that throws errors and also returns a value?
- !try
- try?
- try!
- ?try
What is wrong with this code?
protocol TUI {
func add(x1 : Int, x2 : Int) -> Int {
return x1 + x2
}
}
- Protocol functions cannot have return types.
- Protocol functions cannot have implementations.
- Nothing is wrong with it.
- add is a reserved keyword.
In this code, what are wheels and doors examples of?
class Car {
var wheels: Int = 4
let doors = 4
}
- class members
- This code is invalid.
- class fields
- class properties
How do you designated a failable initializer?
- You cannot
- deinit
- init?
- init
What is printed when this code is executed?
let dbl = Double.init(“5a”)
print(dbl ?? “.asString()”)
- five
- 5a
- .asString()
- 5
In the function below, what are this and toThat examples of?
func add(this x: Int, toThat y: Int)->{}
- none of these answers
- local terms
- argument labels
- parameters names
What is wrong with this code?
for (key, value) in [1: “one”, 2: “two”]{
print(key, value)
}
- The interaction source is invalid
- The interaction variable is invalid
- There is nothing wrong with this code
- The comma in the print is misplaced
Which of these choices is associated with unit testing?
- XCTest
- all of these answers
- @testable
- XCAssert
In the code below, what is width an example of?
class Square{
var height: Int = 0
var width : Int {
return height
}
}
- This code contains error
- a closure
- a computed property
- lazy loading
What data type is this an example of?
let vals = (“val”, 1)
- a dictionary
- a tuple
- an optional
- This code contains error
What is wrong with this code?
var x = 5
x = 10.0
- You cannot assign a Double to a variable of type Int
- x is undefined
- x is a constant
- x has no type
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)
- Any
- test
- 1,2,3
- nil
What is wrong with this code?
let val = 5.0 + 10
- There is nothing wrong with this code
- val is a constant and cannot be changed
- 5.0 and 10 are different types
- There is no semicolon
How many parameters does the initializer for Test have?
struct Test{
var score: Int
var date: Date
}
- zero
- This code contains an error
- two
- Structs do not have initializers
What prints to the console when executing this code?
let x = try? String.init(“test”)
print(x)
- nil
- Nothing – this code contains an error
- Optional(“test”)
- test
How can you sort this array?
var vals = [1,2,3]
- vals.sort { $0 < $1 }
- vals.sort { (s1, s2) in s1 < s2 }
- vals.sort(by: <)
- all of these answers
DispatchQueue.main.async takes a block that will be
- not executed
- executed in the main queue
- none of these answers
- executed on the background thread
When is deinit called?
- When a class instance needs memory
- All of these answers
- When the executable code is finished
- When a class instance is being removed from memory
How do you declare an optional String?
- String?
- Optional[String]
- [String]?
- ?String
How many times this code will be executed? —OR— How many times will this loop be performed?
for i in [“0”, “1”]{
print(i)
}
- one
- two
- three
- This code does not compile
What does this code print?
let names = [“Bear”, “Tony”, “Svante”]
print(names[1]+”Bear”)
- 1Bear
- BearBear
- TonyBear
- Nothing, this code is invalid
What is true of this code?
let name: String?
- name can hold only a string value.
- name can hold either a string or nil value.
- Optional values cannot be let constants.
- Only non-empty string variables can be stored in name.
What is the value of val after this code is executed?
let i = 5
let val = i * 6.0
- This code is invalid.
- 6
- 30
- 0
What does this code print?
enum Positions : Int {
case first, second, third, other
}
print (Positions.other.rawValue)
- 3
- 0
- other
- nil
What is printed to the console when this code is executed?
“t”.forEach { (char) in
print(char)
}
- nil
- Nothing, since the code contains an error
- t
- zero
What prints when this code is executed?
let s1 = [“1”, “2”, “3”]
.filter { $0 > “0” }
.sorted { $0 > $1 }
print(s1)
- []
- [“3”, “2”, “1”]
- [321]
- [“1”, “2”, “3”]
What enumeration feature allows them to store case-specific data?
(Question does not make that much sense though. )
- associated values
- integral values
- raw values
- custom values
In the code below, AOM must be a(n) _?
class AmP : MMM, AOM {
}
- class
- protocol
- enumeration
- struct
What is the value of numbers in the code below?
let numbers = [1,2,3,4,5,6].filter{ $0 % 2 == 0}
- [1,3,5]
- []
- [2,4,6]
- nil
What is the type of vals in this code?
let vals = [“a”, 1, “Hi”]
- Array(char)
- [Any]
- Array<char>
- [Generic]
How can you extract val to x in tuple vt
let vt = (name: “ABC”, val: 5)
- let x = vt.1
- all of these answers
- let x = vt.val
- let (_, x) = vt
What is the type of x: let x = try?
String.init(from: decoder)
- String
- String?
- String!
- try?
How many times is this loop executed?
let loopx = 5
repeat {
print (loopx)
} while loopx < 6
- Six
- Zero
- Five
- Infinite
How many values does vals have after this code is executed?
var vals: Set<String> = [“4”, “5”, “6”]
vals.insert(“5”)
- This code contains an error.
- Eight
- Three
- Four
All Linkedin Skill Assessment Answers
List of Technical Skill Assessment
- LinkedIn .NET Framework Skill Assessment Quiz Answers
- LinkedIn Agile Methodologies Skill Assessment Quiz Answers
- LinkedIn Amazon Web Services (AWS) Skill Quiz Answers
- LinkedIn Android Assessment Quiz Answers
- LinkedIn AngularJS Skill Assessment Quiz Answers
- LinkedIn AWS Lambda Skill Assessment Answers
- LinkedIn Bash Skill Assessment Quiz Answers
- LinkedIn C Skill Assessment Quiz Answers
- LinkedIn C# Skill Assessment Quiz Answers
- LinkedIn C++ Skill Assessment Quiz Answers
- LinkedIn CSS Skill Assessment Quiz Answers
- LinkedIn Cyber Security Skill Assessment Quiz Answers
- LinkedIn Django Skill Assessment Quiz Answers
- LinkedIn Eclipse Skill Assessment Quiz Answers
- LinkedIn Front End Development Skill Assessment Quiz Answers
- LinkedIn Git Skill Assessment Quiz Answers
- LinkedIn Google Analytics Skill Assessment Quiz Answers
- LinkedIn Google Cloud Platform (GCP) Skill Assessment Quiz Answers
- LinkedIn Hadoop Skill Assessment Quiz Answers
- LinkedIn HTML Skill Assessment Quiz Answers
- LinkedIn IT Operation Skill Assessment Quiz Answers
- LinkedIn Java Skill Assessment Quiz Answers
- LinkedIn JavaScript Skill Assessment Quiz Answers
- LinkedIn JQuery Skill Assessment Quiz Answers
- LinkedIn JSON Skill Assessment Quiz Answers
- LinkedIn Windows Server Skill Assessment Quiz Answers
- LinkedIn XML Skill Assessment Answers
- LinkedIn Kotlin Skill Assessment Quiz Answers
- LinkedIn Linux Skill Assessment Quiz Answers
- LinkedIn Machine Learning Skill Assessment Quiz Answers
- LinkedIn Maven Skill Assessment Quiz Answers
- LinkedIn Microsoft Azure Skill Assessment Quiz Answers
- LinkedIn MongoDB Skill Assessment Quiz Answers
- LinkedIn MySQL Skill Assessment Quiz Answers
- LinkedIn Node JS Skill Assessment Quiz Answers
- LinkedIn NoSQL Skill Assessment Quiz Answers
- LinkedIn Objective-C Skill Assessment Quiz Answers
- LinkedIn OOP (Object-Oriented Programming Skill Assessment Quiz Answers
- LinkedIn PHP Skill Assessment Quiz Answers
- LinkedIn Python Skill Assessment Quiz Answers
- LinkedIn React JS Skill Assessment Quiz Answers
- LinkedIn Rest APIs Skill Assessment Quiz Answers
- LinkedIn R (Programming Language) Skill Assessment Quiz Answers
- LinkedIn Ruby on Rails Skill Assessment Quiz Answers
- LinkedIn Scala Skill Assessment Quiz Answers
- LinkedIn Search Engine Optimization (SEO) Skill Assessment Quiz Answers
- LinkedIn Spring Framework Skill Assessment Quiz Answers
- LinkedIn Swift Skill Assessment Quiz Answers
- LinkedIn T-SQL Skill Assessment Quiz Answers
- LinkedIn Unity Skill Assessment Quiz Answers
- LinkedIn Visual Basic for Application (VBA) Skill Assessment Quiz Answers
- LinkedIn WordPress Skill Assessment Quiz Answers
List of Business Skill Assessment
- LinkedIn Accounting Skill Assessment Quiz Answers
- LinkedIn Adobe Acrobat Skill Assessment Quiz Answers
- LinkedIn Google Ads Skill Assessment Quiz Answers
- LinkedIn Microsoft Access Skill Assessment Quiz Answers
- LinkedIn Microsoft Excel Skill Assessment Quiz Answers
- LinkedIn Microsoft Outlook Skill Assessment Quiz Answers
- LinkedIn Microsoft Power BI Skill Assessment Quiz Answers
- LinkedIn Microsoft PowerPoint Skill Assessment Quiz Answers
- LinkedIn Microsoft Project Skill Assessment Quiz Answers
- LinkedIn Microsoft Word Skill Assessment Quiz Answers
- LinkedIn SharePoint Skill Assessment Quiz Answers
- LinkedIn Visio Skill Assessment Quiz Answers
List of Design Skill Assessment