Вы находитесь на странице: 1из 15

1

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

Swift IOS Assessment

While declaring an enumeration, multiple member values can appear in a single line, They are separated
ywhich of the following punctuation marks?
Semi-colon
Colon
Comma
Slash
Point

Which keyword do you use to declare enumeration?


var
enum
struct
case

Which is used for down casting?


as!
is
is?
as?

Which keyword is used in Swift when we want a property of a class to initialize when it is accessed for the firs
me?
let
var
const
lazy

Which one of the below function definitions is wrong considering Swift language?
func haveChar(#string: String, character: Character) -> (Bool)
func mean(numbers: Double)->Double
func minMax(array: [Int]) -> (min: Int?, max: Int?)
func minMax(array: [Int]) -> (min: Int, max: Int)?

Which of the following declares a mutable array in Swift?


var x = [Int]
let x = [Int]
var x = [Int]()

let x = [Int]()

Which of these is not a valid property declaration in Swift?


final let x = 0
final lazy let x = 0
final lazy var x = 0
final var x = 0

Can enumeration type have methods?


Enumerations can have methods associate with them
Enumerations can have only member values

Given that we have defined myChar like so :


t myChar: Character = "b"
Which code segment can be considered a complete Switch statement and will run without any error?

switch myChar { case "a","A": println("The letter A") case "b","B": println("The letter A") }
switch myChar { case "a": println("The letter A") }
switch myChar { case "a": case "A": println("The letter A") default: println("Not the letter A") }
switch myChar { case "a","A": println("The letter A") default: println("Not the letter A") }

Which keyword in the context of a Switch statement is required to force the execution of asubsequent case?

fallthrough
continue
break
return

What types of object are Swift Structures?


Reference Type
Memory Type
Abstract Type
Value Type

What is the name of the deinitializer in a Class declaration?


dealloc
deinit

release

What is the output of this segment of code ?

ar x = 0
r index in 15
++x
intln("\(x)")

Rs. 0.00
compile error
Rs. 5.00
Rs. 4.00

What is used to import Objective-C files into Swift?


Objective-C classes are automatically imported
Objective-C classes are imported in the Swift file using the class
Objective-C classes are imported via a Bridging Header
Objective-C classes import themselves by declare @SwiftImportable

Which one is the correct keyword for defining a constant in Swift?


const
contant
final
let
def

Which one will createa dictionary with a key type of Integer and value of String?
var dict:[Int: String] = ["one":1]
var dict: [Int: String] = [1:"one"]
var dict: [String: Int] = [1:"one"]
var dict = ["one":1]

Objective-C Blocks are translated by using which of the following Swift Language features?
Lambda
Callback
Closure
Selector

Which of these statements is a valid way to extend the capabilities of our theoretical class 'MyClass' to
onform to protocol 'MyProtocol'?
extension MyClass(MyProtocol) { }
extension MyClass, prot MyProtocol { }
extension MyClass: MyProtocol { }
extension MyClass, MyProtocol { }

What does a retainCount represent in ARC?


The current number of strong references to an object
The current number of instances of an object
The total number of objects currently being retained in memory
The total number of times an object has been allocated

All Swift classes must inherit from which root class?


Swift classes do not require a root class
NSObject
@ObjC
Root

Considering var index = UInt8.max, which of the following operation results to the value of zero forvar
ndex?
index = index &- 1
index = index &+ 1
index = index &* 1
index = index &/ 255

What is the name of the Xcode generated header file used to import Swift classes into an Objective-C Class
iven a product module named Example?
ExampleSwift.h
Example.Swift.h
Example+Swift.h
Example-Swift.h

How would you declare a variable named 'awesome' of type 'Double' in Swift?
Double awesome
var: double awesome
var awesome:Double

How do you declare class methods in a Swift class?

class
static
All of the mentioned

What does a mutating keyword indicate?


Indicates a class can mutate its properties
Indicates a method on a struct changes structs values
Indicates that a variable will change during its lifetime

Which of these is not a built-in Swift type?


Boolean
Int
String

How do you declare an Iboutlet property?


@IBOutlet var button:UIButton
var button:UIButton(IBOutlet)
var button:UIButton<outlet>

What is the expected result?

et a = [35,44]
et b = a
[1] = 55

a = [ 33,44]
b = [33, 55]
a = [ 33,55]
b = [33, 55]
compiler will not allow it

Solution

Вам также может понравиться