Upwork Test Answers: Get all the correct answers of most recent and possible Upwork Tests A to Z (Updated on Jan, 2016)
Cover Letter Templates: These cover letter samples are not only for Upwork job, but also you will have some idea about your real life job
 
Freelance Profile Overviews: Different Profile samples and overviews of experts, advanced and intermediate level freelancers
For Newbie of Upwork: Upwork Help - How to apply for a job in Upwork with 10 most important articles about Upwork

A to Z View - All Upwork Test Answers

Swift Test Answers

'Swift is a multi-paradigm, compiled programming language created for iOS, OS X, watchOS and tvOS development by Apple Inc. Swift is designed to work with Apple's Cocoa and Cocoa Touch frameworks and the large body of existing Objective-C code written for Apple products.' (Wikipedia). 

The swift test is an important General Programming test of Upwork. Here in this post, you will find most recent answers of Upwork Swift test. This programming language test can give you a better profile impression in Upwork and which will help you to get the related jobs. Search your desired answers of the test questions by pressing Ctrl + F button.
--------------------------------------------------------------------------------------------------------------------------
1. Which is the wrong definition of a protocol in Swift?
 Answers: • protocol SomeProtocol { var first: Int{ get } }

 2. Which of the following structures has both computed and stored properties?
 Answers: • struct Rect { var origin = CGPointZero var center: CGPoint { get { // } set { // } } }
 
 3. 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: • Example+Swift.h

 4. Considering var index = UInt8.max, which of the following operation results to the value of zero for var index?
 Answers: • index = index &+ 1

 5. Which of these is a valid syntax for iterating through the keys and values of a dictionary?
 let dictionary = [keyOne : valueOne, keyTwo : valueTwo]
 Answers: • for (key, value) in dictionary { println("Key: \(key) Value: \(value)") }

 6. All Swift classes must inherit from which root class?
 Answers: • Swift classes do not require a root class.

 7. What does a retainCount represent in ARC?
 Answers: • The current number of strong references to an object.

 8. Which of these statements is a valid way to extend the capabilities of our theoretical class, MyClass to conform to protocol MyProtocol?
 Answers: • extension MyClass: MyProtocol { }

 9. What is the name of the Swift language feature that Objective-C Blocks are translated into?
 Answers: • Callback

 10. Which keyword is used on a function in an enumeration to indicate that the function will modify 'self'?
 Answers: • mutating

 11. Which is correct for Enumerations?
 Answers: • Enumerations can define initializers.

 12. Which one creates a dictionary with a key type of Integer and value of String?
 Answers: • var dict: [Int: String] = [1:"one"]

 13. Which of these is a valid definition of a generic function that incorporates inout parameters in Swift?
 Answers: • func swap<T>(inout a: T, inout b: T) { let temp = a a = b b = temp }

 14. Which of these is an appropriate syntax for dispatching a heavy operation to a background thread?
 Answers: • dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), { self.heavyOperation() })

 15. Which one is the correct keyword for defining a constant in Swift?
 Answers: • let

 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: • 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: • (String, String) -> String

 18. Which of the following statements could be used to determine if a given variable is of String type?
 Answers: • if unknownVariable is String { }

 19. Which of these could be an appropriate protocol declaration in Swift?
 Answers: • @objc protocol someProtocal { optional var first: Int { get } }

 20. In context of a Swift subscript, which of the following is correct?
 Answers: • struct MyStruct { var myStr = [String]() subscript (index : Int) -> String{ get{ return myStr[index] } set{ myStr[index] = newValue } } }

 21. What is used to import Objective-C files into Swift?
 Answers: • Objective-C classes are automatically imported.

 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: • @inter

 23. What is the output of this segment of code ?
 var x = 0

 for index in 1...5 {
 ++x
 }
 println("\(x)")
 Answers: • 5

 24. What is the name of the deinitializer in a Class declaration?
 Answers: • deinit

 25. Which is correct regarding Swift enumeration members when they are defined?
 Answers: • Members are assigned a default integer value.

 26. What type of object are Swift Structures?
 Answers: • Reference Type

 27. Which keyword in the context of a Switch statement is required to force the execution of a subsequent case?
 Answers: • fallthrough

 28. What is the type of Swift Enumerations?
 Answers: • Reference 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: • switch myChar { case "a": println("The letter A") }

 30. Can enumeration type have methods?
 Answers: • Enumerations can have methods associate with them.

 31. Which of these is an appropriate syntax for declaring a function that takes an argument of a generic type?
 Answers: • func genericFunction<T>(argument: T) { }

 32. Which of these is not a valid property declaration in Swift?
 Answers: • final lazy let x = 0

 33. Which of the following declares a mutable array in Swift?
 Answers: • var x = [Int]

 34. Which one of the below functions definitions is wrong considering Swift language?
 Answers: • func haveChar(#string: String, character: Character) -> (Bool)

 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: • let

 36. Which is used for down casting?
 Answers: • as!

 37. What attribute can be used to allow a protocol to contain optional functions and to be used in ObjC?
 Answers: • objective_bridge

 38. Which of the following types can be used use as raw value types for an enumeration?
 Answers: • Int, String, Float

 39. Which keyword do you use to declare enumeration?
 Answers: • enum

 40. When declaring an enumeration, multiple member values can appear on a single line, separated by which punctuation mark?
 Answers: • Comma