Swift
What is printed to the console when this code is executed? "t".forEach { (char) in; print(char) }
What is this code an example of? let val = (Double)6
What is the result of the following code?func potteryBarn (name: String, score: Int) -> String { return "Hello (name)!Your score is (score)." }potteryBarn ("Tom" , 2)
What is the base class in this code? class LSN : MMM {}
What is wrong with this code? var x = 5; x = 10.0
What is true about Memory management in Swift?
In the below text, what is the name of the class’s only method?Class Square: NamedShape {var sideLength: Doublefunc area() -> Double {return sideLength*sideLength}}
What is the return value of the type check operator - is ?
In the below text, what is the property name?class Square: NamedShape {var sideLength: Double func area() -> Double { return sideLength * sideLength }}
What is the name of the Objective-C Bridging Header given a product module namedExample?
Which is the wrong definition of a protocol in Swift?
Which one is correct function definition?
What is a trailing closure?
What is Swift ?
What is the value of y? let x = ["1", "2"].dropFirst() let y = x[0]
What is wrong with this code? if let s = String.init("some string") { print(s)}
What is the inferred type of x? let x = ["a", "b", "c"]
What is the output of this segment of code:var x = 0 for index in 1...5 { ++x } print("(x)")
Which of these is a valid definition of a generic function that incorporates inoutparameters in Swift?
What is true of this code? let name: String?
What is the value of t after this code is executed? let names = ["Larry", "Sven", "Bear"] let t = names.enumerated().first().offset
What is the correct way to call this function? func myFunc(_ a: Int, b: Int) -> Int {return a + b}
What is Managing Memory in Swift?
What is used in Swift to represent any kind of object?
In the below text, what is the super class name?class Square: NamedShape {var sideLength: Double func area() -> Double { return sideLength * sideLength }}
What is the type of Swift String, Dictionary, Array?
In the below text, what is the class name?Class Square: NamedShape {var sideLength: Doublefunc area() -> Double {return sideLength*sideLength}}
What is the return type of the following code? func nameFunc() -> String { return "Jhon" }
What is the return type in the following declaration:func potteryBarn (name: String, score: Int) -> String { return "Hello (name)!Your score is (score)." }
What is the value of test in this code? var test = 1 == 1
What is the need for having structures?
What is the name of the following function:func potteryBarn (name: String, score: Int) -> String { return "Hello (name)!Your score is (score)." }
____ in Swift is implemented with the is and as operators. These two operators provide a simple and expressive way to check the type of a value or cast a value to a different type?
What is the name of the deinitializer in a Class declaration?
If a class has a superclass and conforms to multiple protocols, what is the correct order to list their names in the initial definition of the Subclass?
How can you use a nested type outside of its definition?
What is the error in this code? let x = 5; guard x == 5 { return }
What is the type name that represents a character in Swift?
What is the output when following statement is executed?import UIKitlet filename:String = "test.dat";let write_data:String = "write data";var read_data:String = "read data";if let directory = NSSearchPathForDirectoriesInDomains(NSSearchPathDirectory.DocumentDirectory, NSSearchPathDomainMask.AllDomainsMask, true).first{let pathname = NSURL(fileURLWithPath:directory).URLByAppendingPathComponent(filename);do {trywrite_data.writeToURL(pathname, atomically: false, encoding: N SUTF8StringEncoding) }catch { print(“write error”) }//readingdo{ read_data = try NSString(contentsOfURL: pathname, encoding: NSUTF8StringEncoding) as String } catch{ print(“read error”) } print(read_data) }
What is the typical byte width of Float data type in Swift?
Which one of the below functions definitions is wrong considering Swift language?
extension Int {subscript(var myInt: Int) -> Int {var no1 = 1while myInt > 0 {no1 *= 10--myInt}return (self / no1) % 10}}print(12[0])What is the output?
What is the name of the Swift language feature that Objective-C Blocks are translatedinto?
What is the value of numbers in the code below? let numbers = [1,2,3,4,5,6].filter{ $0 % 2 == 0}
What is the most basic difference between Value and Reference types?
What is the output when following code is executed? import UIKit import AVFoundation var p: AVAudioPlayer? func func(filename:String) { let url = NSBundle.mainBundle().URLForResource(filename, withExtension: "caf")! do { p = try AVAudioPlayer(contentsOfURL: url) guard let p = p else { return } … … … p.prepareToPlay() p.play() } catch let error as NSError { print(error.description) } }
What is a muting instance method in Swift?
What is the value of y? var x: Int? let y = x ?? 5
What is the output of this segment of code?var x = 0for index in 1...5 {++x}println("\(x)")
What is the correct way to import Objective-C files into Swift?