Upwork SWIFT TEST 2016

Hello Freelancer, Welcome to allupworktestanswers.com Here to get the SWIFT TEST of Latest version 2016. We are ready here to provide your desire upwork test answer. We already tested all exam test information Available include on here. So Dear, Why Late? Read the below full exam test and get more information from our website.


1. Which of these is an appropriate syntax for dispatching a heavy operation to a background thread?

Answers:
  1. dispatch_async(DISPATCH_QUEUE_PRIORITY_BACKGROUND), { self.heavyOperation() })
  2. dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), { self.heavyOperation() })
  3. DISPATCH_QUEUE_PRIORITY_BACKGROUND({ self.heavyOperation() })
  4. dispatch_async({ self.heavyOperation() })
2. Which is the wrong definition of a protocol in Swift?
Answers:
  1. protocol SomeProtocol { var first: Int{ get } }
  2. protocol SomeProtocol { var first: Int{ set } }
  3. protocol SomeProtocol { var first: Int { get set } }
  4. protocol SomeProtocol { var first: Int { get set } var second: Int { get } }
3. Which of the following structures has both computed and stored properties?
Answers:
  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) }
4. What is the name of the Xcode generated header file used to import Swift classes into an Objective-C Class given a product module named Example?
Answers:
  1. ExampleSwift.h
  2. Example.Swift.h
  3. Example+Swift.h
  4. Example-Swift.h
5. Considering var index = UInt8.max, which of the following operation results to the value of zero for var index?
Answers:
  1. index = index &- 1
  2. index = index &+ 1
  3. index = index &* 1
  4. index = index &/ 255
6. Which of these is a valid syntax for iterating through the keys and values of a dictionary?
let dictionary = [keyOne : valueOne, keyTwo : valueTwo]
Answers:
  1. for (key, value) in dictionary { println(“Key: (key) Value: (value)”) }
  2. for (key, value) in enumerate(dictionary) { println(“Key: (key) Value: (value)”) }
  3. for (key, value) in (dictionary.keys, dictionary.values) { println(“Key: (key) Value: (value)”) }
  4. for (key, value) in dictionary.enumerate() { println(“Key: (key) Value: (value)”) }
7. All Swift classes must inherit from which root class?
Answers:
  1. Swift classes do not require a root class.
  2. NSObject
  3. @ObjC
  4. Root
8. What does a retainCount represent in ARC?
Answers:
  1. The current number of strong references to an object.
  2. The current number of instances of an object.
  3. The total number of objects currently being retained in memory.
  4. The total number of times an object has been allocated.
9. Which of these statements is a valid way to extend the capabilities of our theoretical class, MyClass to conform to protocol MyProtocol?
Answers:
  1. extension MyClass(MyProtocol) { }
  2. extension MyClass, prot MyProtocol { }
  3. extension MyClass: MyProtocol { }
  4. extension MyClass, MyProtocol { }
10. What is the name of the Swift language feature that Objective-C Blocks are translated into?
Answers:
  1. Lambda
  2. Callback
  3. Closure
  4. Selector
11. Which keyword is used on a function in an enumeration to indicate that the function will modify ‘self’?
Answers:
  1. modifier
  2. mutating
  3. mutable
  4. mod
  5. mut
12. Which is correct for Enumerations?
Answers:
  1. Enumerations can define initializers.
  2. Enumerations cannot conform to protocols.
  3. Enumerations cannot conform to protocols.
13. Which one creates a dictionary with a key type of Integer and value of String?
Answers:
  1. var dict:[Int: String] = [“one”:1]
  2. var dict: [Int: String] = [1:”one”]
  3. var dict: [String: Int] = [1:”one”]
  4. var dict = [“one”:1]
14. Which of these is a valid definition of a generic function that incorporates inout parameters in Swift?
Answers:
  1. func swap<T>(inout a: T, inout b: T) { let temp = a a = b b = temp }
  2. func swap<U,T>(inout a: U, inout b: T) { let temp = a a = b b = temp }
  3. func swap<U,T>( a: U, b: T) { let temp = a a = b b = temp }
  4. func swap<T>( a: T, b: T) { let temp = a a = b b = temp }
15. Which one is the correct keyword for defining a constant in Swift?
Answers:
  1. const
  2. contant
  3. final
  4. let
  5. def
16. If we have a class named MyClass with a nested enum called Status, declared like so:
class MyClass {
enum Status {
case On, Off
}
}
How would one indicate that a variable is an enum of type Status outside the context of MyClass?
Answers:
  1. var status: MyClass.Status = .On
  2. var status: Status = .On
  3. var status: MyClass<Status> = .On
  4. var status: MyClass(Status) = .On
17. Which of the following could be used to indicate the Function Type of the following function:
func joinStrings(stringOne: String, stringTwo: String) -> String {
return stringOne + stringTwo
}
Answers:
  1. func(String, String -> String)
  2. (String, String) -> String
  3. {String, String} -> String
  4. {String, String}(String)
18. Which of the following statements could be used to determine if a given variable is of String type?
Answers:
  1. if String.hierarchy(unknownVariable) { }
  2. if unknownVariable is String { }
  3. if unkownVariable: String { }
  4. if (String)unknownVariable { }
19. Which of these could be an appropriate protocol declaration in Swift?
Answers:
  1. @objc protocol someProtocal { optional var first: Int { get } }
  2. @objc protocol someProtocal { optional var first: Int { set } }
  3. protocol someProtocal { optional var first: Int { get } }
  4. protocol someProtocal { var first: Int { set } }
20. In context of a Swift subscript, which of the following is correct?
Answers:
  1. struct MyStruct { var myStr = [String]() subscript (index : Int) -> String{ get{ return myStr[index] } set{ myStr[index] = newValue } } }
  2. struct MyStruct { var myStr = [String]() subscript (index : Int) -> Int{ get{ return myStr[index] } set(newValue){ myStr[index] = newValue } } }
  3. struct MyStruct { var myStr = [String]() subscript (index : Int) -> String{ get(){ return myStr[index] } set(newValue){ myStr[index] = newValue } } }
  4. struct MyStruct { var myStr = [String] subscript (index : Int) -> String{ get(){ return myStr[index] } set(newValue){ myStr[index] = newValue } } }
21. What is used to import Objective-C files into Swift?
Answers:
  1. Objective-C classes are automatically imported.
  2. Objective-C classes are imported in the Swift file using the class.
  3. Objective-C classes are imported via a Bridging Header.
  4. Objective-C classes import themselves by declare @SwiftImportable.
22. What keyword is used to indicate a custom operator that will appear in between two targets, similar to the addition operator in this example?
var sum = 10 + 10
Answers:
  1. @inter
  2. between
  3. infix
  4. @center
23. What is the output of this segment of code ?
var x = 0
for index in 1…5 {
++x
}
println(“(x)”)
Answers:
  1. 0
  2. compile error
  3. 5
  4. 4
24. What is the name of the deinitializer in a Class declaration?
Answers:
  1. deinit
  2. dealloc
  3. release
25. Which is correct regarding Swift enumeration members when they are defined?
Answers:
  1. Members are assigned a default integer value.
  2. Members are assigned a random default integer value.
  3. Members are not assigned default integer values.
26. What type of object are Swift Structures?
Answers:
  1. Reference Type
  2. Memory Type
  3. Abstract Type
  4. Value Type
27. Which keyword in the context of a Switch statement is required to force the execution of a subsequent case?
Answers:
  1. fallthrough
  2. continue
  3. break
  4. return
28. What is the type of Swift Enumerations?
Answers:
  1. Reference type
  2. Class type
  3. Collection type
  4. Value type
29. Given that we have defined myChar like so :
let myChar: Character = “b”
Which code segment can be considered a complete Switch statement and will run without any error?
Answers:
  1. switch myChar { case “a”,”A”: println(“The letter A”) case “b”,”B”: println(“The letter A”) }
  2. switch myChar { case “a”: println(“The letter A”) }
  3. switch myChar { case “a”: case “A”: println(“The letter A”) default: println(“Not the letter A”) }
  4. switch myChar { case “a”,”A”: println(“The letter A”) default: println(“Not the letter A”) }
30. Can enumeration type have methods?
Answers:
  1. Enumerations can have methods associate with them.
  2. Enumerations can have only member values.
31. Which of these is an appropriate syntax for declaring a function that takes an argument of a generic type?
Answers:
  1. func genericFunction(argument: T<Generic>) { }
  2. func genericFunction<T>(argument) { }
  3. generic func genericFunction(argument: T) { }
  4. func genericFunction<T>(argument: T) { }
32. Which of these is not a valid property declaration in Swift?
Answers:
  1. final let x = 0
  2. final lazy let x = 0
  3. final lazy var x = 0
  4. final var x = 0
33. Which of the following declares a mutable array in Swift?
Answers:
  1. var x = [Int]
  2. let x = [Int]
  3. var x = [Int]()
  4. let x = [Int]()
34. Which one of the below functions definitions is wrong considering Swift language?
Answers:
  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?)
35. Which keyword is used in Swift when we want a property of a class to initialize when it is accessed for the first time?
Answers:
  1. let
  2. var
  3. const
  4. lazy
36. Which is used for down casting?
Answers:
  1. as!
  2. is
  3. is?
  4. as?
37. What attribute can be used to allow a protocol to contain optional functions and to be used in ObjC?
Answers:
  1. objective_bridge
  2. ObjC
  3. _objc
  4. @objc
38. Which of the following types can be used use as raw value types for an enumeration?
Answers:
  1. Bool
  2. Array
  3. Int, String, Float
  4. Dictionary
39. Which keyword do you use to declare enumeration?
Answers:
  1. var
  2. enum
  3. struct
  4. case
40. When declaring an enumeration, multiple member values can appear on a single line, separated by which punctuation mark?
Answers:
  1. Semi-colon
  2. Colon
  3. Comma
  4. Slash
  5. Point


Finally no more words require about the SWIFT TEST  information in this session of this content. If you are require knowing more, Please ask to us via our contact us form or comment box. Please make sure that, you don’t send Personal information via the Comment box.  Thank you very mutch for being with us.

0 comments: