Correct Answer:
All of these answers
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
[Any]
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
[2,4,6]
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
Protocol
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
Associated values
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
t
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
This code is invalid.
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
Name can hold either a string or nil value.
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
TonyBear
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
Two
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
String?
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
All of these answers
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
Executed in the main queue
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
All of these answers
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
Optional("test")
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
There is nothing wrong with this code
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
You cannot assign a Double to a variable of type Int
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
A tuple
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
All of these answers
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
There is nothing wrong with this code
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
Argument labels
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
Init?
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
Try?
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
Array
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
DispatchQueue.global
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
A designated initializer
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
MMM
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
ABC
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
This code is invalid.
This code does not compile.
Note: This question has more than 1 correct answers
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
All of these answers
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
101
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
All of these answers
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
Structs
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
Self
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
Typealias CustomClosure: () -> ()
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
This String initializer does not return an optional.
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
Use a capture list to set class instances of weak or unowned.
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
This code contains an error.
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
Property observers
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
A constant named val of type Int
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
When it's executed after the function returns
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
String
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
A combination of Encodable and Decodable
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
MyFunc(5, b: 6)
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
(Int, Int) -> Int
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
5
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
TRUE
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
This code contains an error
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
All of these answers.
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
There is none.
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
The guard is missing the else.
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
A syntax issue
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
-128 to 127
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
Dictionary and Set
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
String Literal
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
No
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
True
Note: This Question is unanswered, help us to find answer for this one
var varB = 3.14159ng is the c
varB is inferred to be of type _____
Correct Answer:
Double
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
Hello
World!
Note: This question has more than 1 correct answers
Note: This Question is unanswered, help us to find answer for this one
var myVar = 100
myVar = "Hello World"
print(varA)
The output will be
Correct Answer:
Compile time error
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
True
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
ProjectName-Bridging-Header.h
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
Both
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
Convenience initializer
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
True
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
True
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
#import "CustomObject.h"
Note: This Question is unanswered, help us to find answer for this one
The following are collection types in Swift
Note: There may be more than one right answer.
Correct Answer:
String
Array
Dictionary
Set
Note: This question has more than 1 correct answers
Note: This Question is unanswered, help us to find answer for this one
var myName: Int = "John Doe"
print(myName)
The output will be
Correct Answer:
Compile-time error
Note: This Question is unanswered, help us to find answer for this one
The 'let' keyword is considered as:
Note: There may be more than one right answer.
Correct Answer:
Constant
read only
Thread safe
Note: This question has more than 1 correct answers
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
Typealias
Note: This Question is unanswered, help us to find answer for this one
In Swift, private properties of a class can be accessed in any of it's extension.
Correct Answer:
False
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
False
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
Implement the Codable protocol
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
Deallocation
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
Allocation
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
4 bytes
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
Optional
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
Non-optional
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
UI Thread
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
All of the above
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
None
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
Both
Note: This Question is unanswered, help us to find answer for this one
func addStudent(_ student: Student) {
concurrentStudentQueue.async(flags: .barrier) {
self._students.append(student)
DispatchQueue.main.async { //
self.postContentAddedNotification()
}
}
}
The code will ensure that the submitted DispatchWorkItem will be executed in parallel with any other DispatchWorkItem in the same queue.
Correct Answer:
False
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
FIFO
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
False
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
All
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
True
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
True
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
Keys and Values can be of different types
Note: This Question is unanswered, help us to find answer for this one
Extension can be used to create a new nested type of the following:
Note: There may be more than one right answer.
Correct Answer:
Class
Structure
Enumeration
Note: This question has more than 1 correct answers
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
Mutating
Note: This Question is unanswered, help us to find answer for this one
Which of the following are true about extension functionalities?
Note: There may be more than one right answer.
Correct Answer:
They Can define instance and type methods.
They Can define subscripts
They Can define and use new nested types
Note: This question has more than 1 correct answers
Note: This Question is unanswered, help us to find answer for this one
extension Int {
subscript(var myInt: Int) -> Int {
var no1 = 1
while myInt > 0 {
no1 *= 10
--myInt
}
return (self / no1) % 10
}
}
print(12[0])
What is the output?
Correct Answer:
2
Note: This Question is unanswered, help us to find answer for this one
After importing Objective-C code to Swift, the above method will be imported as
(instancetype)initWithFrame:(CGRect)frame
style:(UITableViewStyle)style;
Correct Answer:
init(frame: CGRect, style: UITableViewStyle) { }
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
Swift initializer syntax.
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
optional
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
Strong
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
strVar cannot be initialized with nil
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
Machine Code
Note: This Question is unanswered, help us to find answer for this one
What is the correct way to import Objective-C files into Swift?
Correct Answer:
Objective-C classes are imported via a Bridging Header.
Note: This Question is unanswered, help us to find answer for this one
What is the return type of the following code? func nameFunc() -> String { return "Jhon" }
Correct Answer:
String
Note: This Question is unanswered, help us to find answer for this one
The following attribute can be used to allow a protocol to contain optional functions and to be used in ObjC?
Correct Answer:
@objc
Note: This Question is unanswered, help us to find answer for this one
Suppose below variable declaration, select a right answer? import UIKit var str = "string" var ŝanĝiĝema = "хувьсагч" var & = "&"
Correct Answer:
3rd declaration is invalid
Note: This Question is unanswered, help us to find answer for this one
How can you fix the missing characters for the following code? func userScore -> Bool { return true }
Correct Answer:
()
Note: This Question is unanswered, help us to find answer for this one
How to hide status bar in iOS app with Swift as follows?
Correct Answer:
We need set UIApplication.sharedApplication().statusBarHidden=true; with viewWillAppear() function overriding
Note: This Question is unanswered, help us to find answer for this one
Which of the following is an appropriate syntax for dispatching a heavy operation to a background thread?
Correct Answer:
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), { self.heavyOperation() })
Note: This Question is unanswered, help us to find answer for this one
If a class is named 'MyClass' with a nested enum called 'Status', how do you indicate that a variable is an enum of type 'Status' outside the context of 'MyClass'? class MyClass { enum Status { case On, Off } }
Correct Answer:
var status: MyClass.Status = .On
Note: This Question is unanswered, help us to find answer for this one
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) } }
Correct Answer:
Plays audio caf file in the resource folder of the bundle
Note: This Question is unanswered, help us to find answer for this one
Based on var index = UInt8.max, which of the following operation results to the value of zero for var index?
Correct Answer:
index = index &+ 1
Note: This Question is unanswered, help us to find answer for this one
Which of the following is the correct keyword for defining a constant in Swift?
Correct Answer:
let
Note: This Question is unanswered, help us to find answer for this one
The following keyword in the context of a Switch statement is required to force the execution of a subsequent case?
Correct Answer:
fallthrough
Note: This Question is unanswered, help us to find answer for this one
Which of the following statements is a valid way to extend the capabilities of our theoretical class, MyClass to conform to protocol MyProtocol?
Correct Answer:
extension MyClass: MyProtocol { }
Note: This Question is unanswered, help us to find answer for this one
In Swift, objects are usually references to instances for both _____ and classes?
Correct Answer:
structures
Note: This Question is unanswered, help us to find answer for this one
What is the return value of the type check operator - is ?
Correct Answer:
true, false
Note: This Question is unanswered, help us to find answer for this one
Which integer literals have a decimal value of 17? (choose all that apply)
Correct Answer:
let decimalInteger = 17
let octalInteger = 0o21
let hexadecimalInteger = 0x11
Note: This question has more than 1 correct answers
Note: This Question is unanswered, help us to find answer for this one
What is the correct way to declare Decomposed Tuple?
Correct Answer:
let (a, b, c, d) = rectangle
Note: This Question is unanswered, help us to find answer for this one
How do you remove items from arrays? (choose all that apply)
Correct Answer:
arry.removeLast()
arry.removeAtIndex(0)
arry.removeAll(keepCapacity: false)
Note: This question has more than 1 correct answers
Note: This Question is unanswered, help us to find answer for this one
What are the Numeric Integer Literals? (choose all that apply)
Correct Answer:
A decimal number, with no prefix
A binary number, with a 0b prefix
An octal number, with a 0o prefix
A hexadecimal number, with a 0x prefix
Note: This question has more than 1 correct answers
Note: This Question is unanswered, help us to find answer for this one
Which of the following is a correct answer for Enumerations?
Correct Answer:
Enumerations can define initializers.
Note: This Question is unanswered, help us to find answer for this one
How to extract a string from URL data?
Correct Answer:
import UIKit
var url = "http://www.google.com/ss.js?id=123456789";
var id = url.componentsSeparatedByString("id=");
print(id[1]) ;
Note: This Question is unanswered, help us to find answer for this one
Which of the following statements are true about Tuple?
Correct Answer:
Group multiple values of any type into a single compound value
Note: This Question is unanswered, help us to find answer for this one
In Swift, what are the benefits of classes?
Correct Answer:
All of the above
Note: This Question is unanswered, help us to find answer for this one
When the following code is executed, what it will do? funcfunc() { let layer = UIApplication.sharedApplication().keyWindow!.layer let scale = UIScreen.mainScreen().scale UIGraphicsBeginImageContextWithOptions(layer.frame.size, false, scale); layer.renderInContext(UIGraphicsGetCurrentContext()!) let s = UIGraphicsGetImageFromCurrentImageContext() UIGraphicsEndImageContext() UIImageWriteToSavedPhotosAlbum(s, nil, nil, nil) }
Correct Answer:
It gets full screenshot and will save it as JPG file in photo folder
Note: This Question is unanswered, help us to find answer for this one
Select the most proper answer. import UIKit import AVFoundation … … … let r:AVAudioRecorder? do { r = try AVAudioRecorder(URL: soundFileURL, settings: rSettings) r.delegate = self r.meteringEnabled = true r.prepareToRecord() } catch let error as NSError { r = nil print(error.localizedDescription) }
Correct Answer:
It opens audio recording file, and prepares for the audio recording environment
Note: This Question is unanswered, help us to find answer for this one
What is the need for having structures?
Correct Answer:
All of them
Note: This Question is unanswered, help us to find answer for this one
In Swift, what's the correct way variables consist?
Correct Answer:
var> name > type > value
Note: This Question is unanswered, help us to find answer for this one
On which tag background color for the page can be set?
Correct Answer:
<body>
Note: This Question is unanswered, help us to find answer for this one
Compare the below code and what will result?
import UIKit
var rank:Dictionary = [1:”First”, 2: “Second”, 3: “Third”];
rank.updateValue(“Forth”, forKey: 4);
rank[5]=”Fifth”;
for I in rank {
print(i);
}
import UIKit
var rank:Dictionary = [2:”Second”, 1: “First”, 3: “Third”];
rank[5]=”Fifth”;
rank.updateValue(“Forth”, forKey: 4);
for I in rank {
print(i)
}
Correct Answer:
Output Result will be same
Note: This Question is unanswered, help us to find answer for this one
Please check following code and tell what can be problem?
import UIKit ;
var intVar:Int?=3;
intVar = nil;
var strVar:String;
strVar = nil;
Correct Answer:
strVar cannot be initialized with nil
Note: This Question is unanswered, help us to find answer for this one
Execute below code and tell what can be problem? import UIKit let fm = NSFileManager.defaultManager() fm.removeItemAtPath("file.old")
Correct Answer:
If it cannot find file, exception would be occurred, we need exception handling
Note: This Question is unanswered, help us to find answer for this one
Use the classes defined above to create a new Person instance, and try to access its numberOfRooms property as before?
Correct Answer:
let john = Person() if let roomCount = john.residence?.numberOfRooms { println("John's residence has \(roomCount) room(s).") }else{ println("Unable to retrieve the number of rooms.") }
Note: This Question is unanswered, help us to find answer for this one
What does the following code?
import UIKit
var str1:String?="text1";
var str2:String="text2";
var int1:Int?=111;
var int2:Int=222;
var array:String[] = [str1, str2, int1, int2];
array=[];
Correct Answer:
Str2 and int2 cannot be initialized because they are not optional variables.
Note: This Question is unanswered, help us to find answer for this one
Extensions can add new instance ____?
Correct Answer:
methods
Note: This Question is unanswered, help us to find answer for this one
Consider the following code output when the file doesn’t exist?
import UIKit
let filename:String = "testfile";
var readdata:String = "test data";
let pathname = NSURL(fileURLWithPath: "..") URLByAppendingPathComponent(filename) ;
do {
readdata = try NSString(contentsOfURL: pathname, encoding:NSUTF8StringEncoding) as String } catch { print("read error")
}
print(readdata);
Correct Answer:
read error
test data
Note: This question has more than 1 correct answers
Note: This Question is unanswered, help us to find answer for this one
How to convert string into integer value? import UIKit let str_number = "320"
Correct Answer:
let int1_value = Int(str_number)
let int2_value = (str_number as NSString).integerValue
let int4_value = atoi(str_number as String)
Note: This question has more than 1 correct answers
Note: This Question is unanswered, help us to find answer for this one
Choose the correct answer?
import Foundation
import AVFoundation
func startCapture()
{ if let device : AVCaptureDevice = AVCaptureDevice.defaultDeviceWithMediaType(AVMediaTypeAudio){ do { self.session = AVCaptureSession() try device.lockForConfiguration() let audioInput = try AVCaptureDeviceInput(device: device) device.unlockForConfiguration() // audio capture operation … … } catch { } } }
Correct Answer:
If AVFoundation was not imported, it will not work
If audio device was already used, this function cannot work
Note: This question has more than 1 correct answers
Note: This Question is unanswered, help us to find answer for this one
Following code which is super class? class X: Y { let str:String let val:Int? … init() { … } deinit(){ … } }
Correct Answer:
Y is a super class of X
Note: This Question is unanswered, help us to find answer for this one
How to get local IP address in swift?
Correct Answer:
getnameinfo
getIP()
Note: This question has more than 1 correct answers
Note: This Question is unanswered, help us to find answer for this one
Read the following code and select output?
import UIKit
var array:[String] = ["string1", "string2"];
print("array list has (array.count) items.");
Correct Answer:
array list has (array.count) items.
Note: This Question is unanswered, help us to find answer for this one
What is the output when following statement is executed?
import UIKit
let 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 {
try
write_data.writeToURL(pathname, atomically: false, encoding: N SUTF8StringEncoding) }
catch { print(“write error”) }
//reading
do
{ read_data = try NSString(contentsOfURL: pathname, encoding: NSUTF8StringEncoding) as String } catch
{ print(“read error”) } print(read_data) }
Correct Answer:
write data
Note: This Question is unanswered, help us to find answer for this one
The structure of a value or ____ value?
Correct Answer:
struct
Note: This Question is unanswered, help us to find answer for this one
How to compare below 2 strings? let str1 = "string1" let str2 = "string2”
Correct Answer:
if str1 == str2
Note: This Question is unanswered, help us to find answer for this one
Which of the following is safest for downcasting?
Correct Answer:
as?
Note: This Question is unanswered, help us to find answer for this one
If the following code executed what can be problem?
import UIKit
func MinMax(array: [Int]) -> (min: Int, max: Int)
{
var min = array[0];
var max = array[0];
for val in array[1..<array.count] {
if val< min { min = val }
else if val> max { max = val }
}
return (min, max)
}
Correct Answer:
min and max variables should be defined as optional variables
Note: This Question is unanswered, help us to find answer for this one
What will be the output of the following code snippet? let val1 = "Hello," let val2 = "World!" var result = val1 \ val2 print( result )
Correct Answer:
Compiler Error
Note: This Question is unanswered, help us to find answer for this one
A while loop performs a set of statements until a condition becomes false. These kinds of loops are best used when the number of iterations is not known before the first iteration begins. Swift provides two kinds of while loops?
Correct Answer:
All of the above (1st two options are correct)
Note: This Question is unanswered, help us to find answer for this one
Closure expressions in Swift language follow crisp, optimization, and lightweight syntax styles which includes?
Correct Answer:
All of the them
Note: This Question is unanswered, help us to find answer for this one
In Swift there are ____ kinds of types named and Compound?
Correct Answer:
two
Note: This Question is unanswered, help us to find answer for this one
____ 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?
Correct Answer:
Type casting
Note: This Question is unanswered, help us to find answer for this one
ARC tracks how many , , and variables?
Correct Answer:
properties
constants
Note: This question has more than 1 correct answers
Note: This Question is unanswered, help us to find answer for this one
How to connect UI in Swift Language?
Correct Answer:
Same as like c-objective. There is no change in binding process only core level has been changed. You can choose button/label on xib file and binding as is it.
Note: This Question is unanswered, help us to find answer for this one
How to enumerate an enum with String type, using the following code?
Correct Answer:
enum Suit { case Spades, Hearts, Diamonds, Clubs func simpleDescription() -> String { switch self { case .Spades: return "spades" case .Hearts: return "hearts" case .Diamonds: return "diamonds" case .Clubs: return "clubs" } } }
Note: This Question is unanswered, help us to find answer for this one
Storing Swift value types in Core Data?
Correct Answer:
All of the above
Note: This Question is unanswered, help us to find answer for this one
In Swift, a function is defined by the "____"?
Correct Answer:
func
Note: This Question is unanswered, help us to find answer for this one
Define Initializer Role for Stored Properties?
Correct Answer:
All of the above
Note: This Question is unanswered, help us to find answer for this one
Delegation is a design pattern that enables _____?
Correct Answer:
class
Note: This Question is unanswered, help us to find answer for this one
An __ defines a common type for a group of related values and enables you to work with those values in a type-safe way within your code?
Correct Answer:
enumeration
Note: This Question is unanswered, help us to find answer for this one
Which of the following is not a valid data type in Swift?
Correct Answer:
MovieClip
Note: This Question is unanswered, help us to find answer for this one
This represents a Boolean value which is either true or false?
Correct Answer:
Bool
Note: This Question is unanswered, help us to find answer for this one
Which keyword is used to define a constant?
Correct Answer:
let
Note: This Question is unanswered, help us to find answer for this one
The example below defines two variables, movieCount and songCount, which count the number of Movie and Song instances in the library array?
Correct Answer:
var movieCount = 0 var songCount = 0 for item in library { if item is Movie { ++movieCount }else if item is Song { ++songCount } } println("Media library contains \(movieCount) movies and \ (songCount) songs")
Note: This Question is unanswered, help us to find answer for this one
Use func to declare a function. Call a function by following its name with a list of arguments in parentheses. Use -> to separate the parameter names and types from the function’s return type?
Correct Answer:
func greet(name: String, day: String) -> String { return "Hello \(name), today is \(day)." } greet("Bob", "Tuesday")
Note: This Question is unanswered, help us to find answer for this one
__ can require that conforming types have specific instance properties, instance methods, type methods, operators, and subscripts?
Correct Answer:
Protocols
Note: This Question is unanswered, help us to find answer for this one
How do you save local storage data in a swift application?
Correct Answer:
All of the above
Note: This Question is unanswered, help us to find answer for this one
How to get userinfo from NSNotification in swift 3?
Correct Answer:
func downloadProgress(notification:NSNotification){ if let userInfo = notification.userInfo as [String: Any] { print(userInfo) if let progressValue = userInfo["progressPercentage"] as? Float { if progressValue > 0.01{ } } } }
Note: This Question is unanswered, help us to find answer for this one
Protocols can be accessed as types in?
Correct Answer:
All of the above
Note: This Question is unanswered, help us to find answer for this one
Swift has built-in support for checking _____ which ensures that you don’t accidentally use APIs that are unavailable on a given deployment target?
Correct Answer:
API availability
Note: This Question is unanswered, help us to find answer for this one
List out what are the control transfer statements used in Swift?
Correct Answer:
All of the above
Note: This Question is unanswered, help us to find answer for this one
Swift Generics & Upcasting
Correct Answer:
class Fruit {} class Apple: Fruit {} class Orange: Fruit {} class Basket<T: Fruit> { private var items: [T] func add(item: T) { items.append(item) } init() {} } func addItem<T: Fruit>(var basket: Basket<T>, item: T) { basket.add(item) } let basket:Basket<Apple> = Basket() addItem(basket as Basket<Fruit>, Orange())
Note: This Question is unanswered, help us to find answer for this one
Tuples group multiple values into a single _____ value?
Correct Answer:
compound
Note: This Question is unanswered, help us to find answer for this one
What is Swift ?
Correct Answer:
Swift is Apple's latest programming language for iOS and OS X apps that builds on the best of C and Objective-C, without the constraints of C compatibility. Swift adopts safe programming patterns and adds modern features to make programming easier, and flexible.
Note: This Question is unanswered, help us to find answer for this one
What is the difference between let and var in swift? let x = 10 var x = 10
Correct Answer:
C- Both(A,B)
Note: This Question is unanswered, help us to find answer for this one
How to hide status bar in ios app with Swift?
Correct Answer:
We need override prefersStatusBarHidden() function on the view controller to return true always
We need set UIApplication.sharedApplication().statusBarHidden=true; with viewWillAppear() function overriding
Note: This question has more than 1 correct answers
Note: This Question is unanswered, help us to find answer for this one
Which of is not a valid Access control in Swift?
Correct Answer:
protected
Note: This Question is unanswered, help us to find answer for this one
Initialization is the process of preparing an instance of a _____?
Correct Answer:
All of the above
Note: This Question is unanswered, help us to find answer for this one
Restrict extensions on a type in Swift?
Correct Answer:
final class Person { private let name: String func tellName() -> String { return "I am \(name)" } init(name: String) { self.name = name } }
Note: This Question is unanswered, help us to find answer for this one
Which of the following True statments of Closures?
Correct Answer:
All of the above
Note: This Question is unanswered, help us to find answer for this one
Shifting Behavior for Unsigned Integers?
Correct Answer:
Existing bits are moved to the left or right by the requested number of places.
Any bits that are moved beyond the bounds of the integer’s storage are discarded.
Zeros are inserted in the spaces left behind after the original bits are moved to the left or right.
Note: This question has more than 1 correct answers
Note: This Question is unanswered, help us to find answer for this one
What is Managing Memory in Swift?
Correct Answer:
All of the above
Note: This Question is unanswered, help us to find answer for this one
What will be the output of the following code snippet?
var ary1 = [1, 2, 3, 4];
var ary2 = ary1;
ary2.append(5);
var result = ary1.count;
Correct Answer:
4
Note: This Question is unanswered, help us to find answer for this one
What are the features of Swift Programming?
Correct Answer:
All of the above
Note: This Question is unanswered, help us to find answer for this one
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 }
Correct Answer:
(String, String) -> String
Note: This Question is unanswered, help us to find answer for this one
What is the output of this segment of code?
var x = 0
for index in 1...5 {
++x
}
println("\(x)")
Correct Answer:
5
Note: This Question is unanswered, help us to find answer for this one
Which of the following statements about Extensions is false?
Correct Answer:
Extensions can override existing functionality.
Note: This Question is unanswered, help us to find answer for this one
Which one is correct function definition?
Correct Answer:
funcsayHello(personName: String) -> String {}
Note: This Question is unanswered, help us to find answer for this one
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?
Correct Answer:
Super class first, protocols followed by comma.
Note: This Question is unanswered, help us to find answer for this one
Which of these operators is used to check whether or not two instances are identical?
Correct Answer:
==
Note: This Question is unanswered, help us to find answer for this one
Which of the following could be used to loop through the range of numbers 5-12 including 12?
Correct Answer:
for i in 5,i>12,i++
Note: This Question is unanswered, help us to find answer for this one
With which keyword can you declare a constant in Swift?
Correct Answer:
let
Note: This Question is unanswered, help us to find answer for this one
To declare a function in Swift you would use what keyword?
Correct Answer:
func
Note: This Question is unanswered, help us to find answer for this one
In the below text, what is the property name?
class Square: NamedShape {
var sideLength: Double
func area() -> Double {
return sideLength * sideLength
}
}
Correct Answer:
sideLength
Note: This Question is unanswered, help us to find answer for this one
In the below text, what is the super class name?
class Square: NamedShape {
var sideLength: Double
func area() -> Double {
return sideLength * sideLength
}
}
Correct Answer:
NamedShape
Note: This Question is unanswered, help us to find answer for this one
What is the correct way to compare the equality of two String type objects in Swift?
Correct Answer:
==
Note: This Question is unanswered, help us to find answer for this one
Which is not a control transfer statement in Swift?
Correct Answer:
goto
Note: This Question is unanswered, help us to find answer for this one
Which keyword do you use to define a class?
Correct Answer:
class
Note: This Question is unanswered, help us to find answer for this one
What is a mutating instance method in Swift?
Correct Answer:
When instance method without extension can modify itself.
Note: This Question is unanswered, help us to find answer for this one
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
?
Correct Answer:
var status: MyClass.Status = .On
Note: This Question is unanswered, help us to find answer for this one
To declare a constant in Swift you would use:
Correct Answer:
let
Note: This Question is unanswered, help us to find answer for this one
Can Structures be type cast in Swift?
Correct Answer:
No
Note: This Question is unanswered, help us to find answer for this one
What is the output of this segment of code:
var x = 0 for index in 1...5 { ++x } print("(x)")
Correct Answer:
5
Note: This Question is unanswered, help us to find answer for this one
Swift can compile alongside what other language?
Correct Answer:
Objective C
Note: This Question is unanswered, help us to find answer for this one
Which Swift Type is used to group multiple values into a single compound value? For example:let compoundValue = (3, 5)
Correct Answer:
Tuple
Note: This Question is unanswered, help us to find answer for this one
What symbol is used like a tuple to access arguments in Abbreviated Swift Closure syntax?
Correct Answer:
$
Note: This Question is unanswered, help us to find answer for this one
What is the type of Swift Enumerations?
Correct Answer:
Value type
Note: This Question is unanswered, help us to find answer for this one
What is the most basic difference between Value and Reference types?
Correct Answer:
Assigning a Value type to a new variable copies its contents to a new
instance, where Reference types do not.
Note: This Question is unanswered, help us to find answer for this one
What happens when Swifts String, Array, and Dictionary objects are assigned to a new constant or variable?
Correct Answer:
They are copied.
Note: This Question is unanswered, help us to find answer for this one
Which of these collection types is not included by default in standard Swift?
Correct Answer:
NA
Note: This Question is unanswered, help us to find answer for this one
Which of these statements declares cityArray as a mutable array?
Correct Answer:
var cityArray = ["Portland","San Francisco","Cupertino"]
Note: This Question is unanswered, help us to find answer for this one
Which keyword do you use to define a protocol?
Correct Answer:
protocol
Note: This Question is unanswered, help us to find answer for this one
How could we extend String to conform to protocol MyProtocol? Answers:
Correct Answer:
extension String: MyProtocol { }
Note: This Question is unanswered, help us to find answer for this one
Which of the following statements is true when talking about classes and structures in Swift?
Correct Answer:
Both can be extended
Note: This Question is unanswered, help us to find answer for this one
Which keyword is used to declare an extension in Swift?
Correct Answer:
extension
Note: This Question is unanswered, help us to find answer for this one
Which is correct for the following codes?
class Country{ let name: String init(name: String){ self.name = name; } var city: City? } class City{ let name: String init(name: String){ self.name = name; } var country: Country? } var bangladesh: Country? var khulna: City? bangladesh = Country( name: "Bangladesh" ) khulna = City( name: "Khulna" ) bangladesh?.city = khulna khulna?.country = bangladesh bangladesh = nil khulna = nil
Correct Answer:
Neither Country, nor City will be deallocated.
Note: This Question is unanswered, help us to find answer for this one
How can you use a nested type outside of its definition?
Correct Answer:
Prefix its name with the name of the type it is nested within.
Note: This Question is unanswered, help us to find answer for this one
How could we declare a custom protocol that inherits from Equatable?
Correct Answer:
protocol CustomEquatable: Equatable {…}
Note: This Question is unanswered, help us to find answer for this one
Why are IBOutlets declared with a weak attribute by default?
Correct Answer:
IBOutlets are not declared with a weak attribute by default.
Note: This Question is unanswered, help us to find answer for this one
To which of these types does ARC apply?
Correct Answer:
Class
Note: This Question is unanswered, help us to find answer for this one
What is true about Memory management in Swift?
Correct Answer:
Swift uses ARC but we still need to avoid reference cycles using weak and
strong references etc.
Note: This Question is unanswered, help us to find answer for this one
How will ARC handle "Country" instance and "country2" reference when "country1" is set to "nil"?
class Country{ let name: String init(name: String){ self.name = name } } var country1: Country? var country2: Country? country1 = Country(name: "Bangladesh") country2 = country1
Correct Answer:
ARC will not deallocate the Country instance and country2 will hold it’s
name "Bangladesh"
Note: This Question is unanswered, help us to find answer for this one
What will be the final value of "a.data" and "b.data" after following codes are executed?
struct A { var data: Int = 2 } var a = A() var b = a var c = b c.data = 10 a.data = 5
Correct Answer:
a.data = 5 and b.data = 2
Note: This Question is unanswered, help us to find answer for this one
What is the type of Swift String, Dictionary, Array?
Correct Answer:
Class
Note: This Question is unanswered, help us to find answer for this one
Which keyword do you use to define a function?
Correct Answer:
func
Note: This Question is unanswered, help us to find answer for this one
What is the name of the following function: func potteryBarn (name: String, score: Int) -> String { return "Hello (name)! Your score is (score)." }
Correct Answer:
potteryBarn
Note: This Question is unanswered, help us to find answer for this one
AnyObject can represent:
Correct Answer:
an instance of any class type.
Note: This Question is unanswered, help us to find answer for this one
Which of these is an invalid constant or variable declaration?
Correct Answer:
let = 3.14159
Note: This Question is unanswered, help us to find answer for this one
To loop through a range of the numbers 1-9 without using 9, you would write…
Correct Answer:
for i in 1..<9
Note: This Question is unanswered, help us to find answer for this one
Which is the correct optional form of a down cast operator?
Correct Answer:
as?
Note: This Question is unanswered, help us to find answer for this one
What are the names of the input parameters in the following function: func potteryBarn (name: String, score: Int) -> String {return "Hello (name)! Your score is (score)."}
Correct Answer:
name, score
Note: This Question is unanswered, help us to find answer for this one
What is the return type in the following declaration: func potteryBarn (name: String, score: Int) -> String { return "Hello (name)! Your score is (score)." }
Correct Answer:
String
Note: This Question is unanswered, help us to find answer for this one
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)
Correct Answer:
Hello Tom! Your score is 2.
Note: This Question is unanswered, help us to find answer for this one
When declaring a function, what symbol is used to indicate that an internal parameter name should also be used as an external parameter?
Correct Answer:
_ (right answer)
Note: This Question is unanswered, help us to find answer for this one
In what order will the following statements appear in the console? println("1") dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY _DEFAULT, 0), {println("2")}); println("3")
Correct Answer:
1/3/2
Note: This Question is unanswered, help us to find answer for this one
In what queue should all UI code be handled?
Correct Answer:
MainQueue
Note: This Question is unanswered, help us to find answer for this one
Which of the following is correct to cube Integer?
Correct Answer:
extension Int { mutating func cube () { self = selfselfself } }
Note: This Question is unanswered, help us to find answer for this one
What will happen if you assign a value to a property within its own didSet observer?
Correct Answer:
The property will take on that value
Note: This Question is unanswered, help us to find answer for this one
Which of following expressions can be used to rewrite the following UITableView instantiation in Swift UITableView *myTableView = [[UITableView alloc] initWithFrame: CGRectZero style: UITableViewStyleGrouped];
Correct Answer:
let myTableView: UITableView = UITableView(frame: CGRectZero,
style: .Grouped);
Note: This Question is unanswered, help us to find answer for this one
What aspect of iOS development requires the use of NSOperation and/or Grand Central Dispatch (GCD)?
Correct Answer:
Multithreading
Note: This Question is unanswered, help us to find answer for this one
In the below text, what is the name of the class’s only method? Class Square: NamedShape { var sideLength: Double func area() -> Double { return sideLength*sideLength } }
Correct Answer:
area
Note: This Question is unanswered, help us to find answer for this one
In the below text, what is the class name? Class Square: NamedShape { var sideLength: Double func area() -> Double { return sideLength*sideLength } }
Correct Answer:
Square
Note: This Question is unanswered, help us to find answer for this one
In the below text, what type of return does the function ‘area’ give? Class Square: NamedShape { var sideLength: Double func area() -> Double { return sideLength*sideLength } }
Correct Answer:
Double
Note: This Question is unanswered, help us to find answer for this one
Which of following statements about functions is wrong?
Correct Answer:
In-out parameters might have a default value
Note: This Question is unanswered, help us to find answer for this one
What specifies custom infix operator?
Correct Answer:
it is a binary operator, taking a left and right hand argument
Note: This Question is unanswered, help us to find answer for this one
What are the available arithmetic overflow operators in Swift?
Correct Answer:
&+,&-,&*,&/,&%
Note: This Question is unanswered, help us to find answer for this one
Which of the following statements is true regarding Swift closures and functions?
Correct Answer:
A Function is a named Closure
Note: This Question is unanswered, help us to find answer for this one
What is a trailing closure?
Correct Answer:
A closure expression that is written outside of (and after) the parentheses
of the function call it supports.
Note: This Question is unanswered, help us to find answer for this one
How could the following closure be rewritten to use shorthand arguments? s2 } ) >
Correct Answer:
reversed = sorted(names, { $0 > $1 } )
Note: This Question is unanswered, help us to find answer for this one
How could you call the following function that takes a closure as an argument using trailing closure syntax: ()) { // function body goes here }>
Correct Answer:
funcWithClosure() { //closure’s body goes here }
Note: This Question is unanswered, help us to find answer for this one
Let’s assume "numbers" is an array of unsorted integers. Which of these could be used to sort numbers?
Correct Answer:
numbers.sort({$0 > $1})
Note: This Question is unanswered, help us to find answer for this one
Choose the answer that declares an optional closure.
Correct Answer:
var closureName: ((parameterTypes) -> (returnType))
Note: This Question is unanswered, help us to find answer for this one
How can we use optional binding to determine if the variable string is not nil?
Correct Answer:
if let str = string {…}
Note: This Question is unanswered, help us to find answer for this one
What set of keywords is most commonly used to iterate over a collections of items?
Correct Answer:
for in
Note: This Question is unanswered, help us to find answer for this one
How could we cast the following array into an NSArray that accesses the NSArray method:
componentsJoinedByString() < let arr = ["1", "2", "3"]
Correct Answer:
(arr as NSArray).componentsJoinedByString(",")
Note: This Question is unanswered, help us to find answer for this one
How could one declare a Swift Array type that can store any type of class object?
Correct Answer:
var arr: [AnyObject] = [ ]
Note: This Question is unanswered, help us to find answer for this one
Which is correct regarding optional form of the type cast operator (as?)?
Correct Answer:
Return value will be nil if the downcast was not possible
Note: This Question is unanswered, help us to find answer for this one
How could we create a subclass of the Structure, CGRect?
Correct Answer:
You can not subclass a Structure
Note: This Question is unanswered, help us to find answer for this one
Considering the following code, which statement is Correct:
let array1 = ["A", "B", "C"] var array2 = array1 array2.append("D")
Correct Answer:
Reference count of array1 won't change after the assignment
Note: This Question is unanswered, help us to find answer for this one
Swift Extensions are similar to categories in Objective-C except:
Correct Answer:
Swift extensions are not named.
Note: This Question is unanswered, help us to find answer for this one
What is a muting instance method in Swift?
Correct Answer:
When instance method without extension can modify itself.
Note: This Question is unanswered, help us to find answer for this one
What is the type name that represents a character in Swift?
Correct Answer:
Character
Note: This Question is unanswered, help us to find answer for this one
What is the name of the Objective-C Bridging Header given a product module named Example?
Correct Answer:
Example-Bridging-Header.h
Note: This Question is unanswered, help us to find answer for this one
What is used in Swift to represent any kind of object?
Correct Answer:
AnyObject
Note: This Question is unanswered, help us to find answer for this one
How do closures capture references to variables by default ?
Correct Answer:
By strong reference
Note: This Question is unanswered, help us to find answer for this one
When declaring an enumeration, multiple member values can appear on a single line, separated by which punctuation mark?
Correct Answer:
Comma
Note: This Question is unanswered, help us to find answer for this one
Which keyword do you use to declare enumeration?
Correct Answer:
enum
Note: This Question is unanswered, help us to find answer for this one
Which of the following types can be used use as raw value types for an enumeration?
Correct Answer:
Int, String, Float
Note: This Question is unanswered, help us to find answer for this one
Which is used for down casting?
Correct Answer:
as!
as?
Note: This question has more than 1 correct answers
Note: This Question is unanswered, help us to find answer for this one
Which keyword is used in Swift when we want a property of a class to initialize when it is accessed for the first time?
Correct Answer:
lazy
Note: This Question is unanswered, help us to find answer for this one
Which of the following declares a mutable array in Swift?
Correct Answer:
var x = [Int]()
Note: This Question is unanswered, help us to find answer for this one
Can enumeration type have methods?
Correct Answer:
Enumerations can have methods associate with them.
Note: This Question is unanswered, help us to find answer for this one
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?
Correct Answer:
switch myChar { case "a","A": println("The letter A") default:
println("Not the letter A") }
Note: This Question is unanswered, help us to find answer for this one
What type of object are Swift Structures?
Correct Answer:
Value Type
Note: This Question is unanswered, help us to find answer for this one
Which is correct regarding Swift enumeration members when they are defined?
Correct Answer:
Members are not assigned default integer values.
Note: This Question is unanswered, help us to find answer for this one
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
Correct Answer:
infix
Note: This Question is unanswered, help us to find answer for this one
What is used to import Objective-C files into Swift?
Correct Answer:
Objective-C classes are imported via a Bridging Header.
Note: This Question is unanswered, help us to find answer for this one
In context of a Swift subscript, which of the following is correct?
Correct Answer:
struct MyStruct { var myStr = [String]() subscript (index :
Int) -> String{ get{ return myStr[index] } set{ myStr[index]
= newValue } } }
Note: This Question is unanswered, help us to find answer for this one
Which of these could be an appropriate protocol declaration in Swift?
Correct Answer:
@objc protocol someProtocal { optional var first: Int { get } }
Note: This Question is unanswered, help us to find answer for this one
Which of the following statements could be used to determine if a given variable is of String type?
Correct Answer:
if unknownVariable is String { }
Note: This Question is unanswered, help us to find answer for this one
Which of these is a valid definition of a generic function that incorporates inout parameters in Swift?
Correct Answer:
func swap<T>(inout a: T, inout b: T) { let temp = a a = b
b = temp }
Note: This Question is unanswered, help us to find answer for this one
Which keyword is used on a function inside an Enumeration to indicate that the function will modify 'self'?
Correct Answer:
mutating
Note: This Question is unanswered, help us to find answer for this one
All Swift classes must inherit from which root class?
Correct Answer:
Swift classes do not require a root class.
Note: This Question is unanswered, help us to find answer for this one
Which of the following structures has both computed and stored properties?
Correct Answer:
struct Rect { var origin = CGPointZero var center: CGPoint {
get { // } set { // } } }
Note: This Question is unanswered, help us to find answer for this one
Which is the wrong definition of a protocol in Swift?
Correct Answer:
protocol SomeProtocol { var first: Int{ set } }
Note: This Question is unanswered, help us to find answer for this one
Which of these is not a valid property declaration in Swift?
Correct Answer:
final lazy let x = 0
Note: This Question is unanswered, help us to find answer for this one
Which of these is an appropriate syntax for declaring a function that takes an argument of a generic type?
Correct Answer:
func genericFunction<T>(argument: T) { }
Note: This Question is unanswered, help us to find answer for this one
What is the name of the deinitializer in a Class declaration?
Correct Answer:
deinit
Note: This Question is unanswered, help us to find answer for this one
Which of these is an appropriate syntax for dispatching a heavy operation to a background thread?
Correct Answer:
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIO
RITY_BACKGROUND, 0), { self.heavyOperation() })
Note: This Question is unanswered, help us to find answer for this one
Which one creates a dictionary with a key type of Integer and value of String?
Correct Answer:
var dict: [Int: String] = [1:"one"]
Note: This Question is unanswered, help us to find answer for this one
What is the name of the Swift language feature that Objective-C Blocks are translated into?
Correct Answer:
Closure
Note: This Question is unanswered, help us to find answer for this one
Which of these is a valid syntax for iterating through the keys and values of a dictionary?
let dictionary = [keyOne : valueOne, keyTwo : valueTwo]
Correct Answer:
for (key, value) in dictionary { println("Key: (key) Value: (value)") }
for (key, value) in dictionary.enumerate() { println("Key: (key) Value:
(value)") }
Note: This question has more than 1 correct answers
Note: This Question is unanswered, help us to find answer for this one
Which one of the below functions definitions is wrong considering Swift language?
Correct Answer:
func haveChar(#string: String, character: Character) -> (Bool)
Note: This Question is unanswered, help us to find answer for this one
What does a retainCount represent in ARC?
Correct Answer:
The current number of strong references to an object.
Note: This Question is unanswered, help us to find answer for this one
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?
Correct Answer:
Example-Swift.h
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
Assignment operator (=)
Ternary conditional operator (?:)
Note: This question has more than 1 correct answers
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
8% 2 returns 0
23 % 7.5 returns 0.5
Note: This question has more than 1 correct answers
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
They can be used as a return type in a function.
They can be used as the type of items in a dictionary.
Note: This question has more than 1 correct answers
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
An Apple Swift property does not have a corresponding instance variable.
Computed properties can be defined by enumerations in the Apple Swift language.
Note: This question has more than 1 correct answers
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
?:
??
Note: This question has more than 1 correct answers
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
Global constants
Global variables
Note: This question has more than 1 correct answers
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
Methods can be defined by structures to provide functionality.
Reference counting permits more than one reference to a structure instance.
Note: This question has more than 1 correct answers
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
There can be at most two deinitializers per class.
A deinitializer always takes one parameter.
Note: This question has more than 1 correct answers
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
They can define type methods.
They can add computed properties.
Note: This question has more than 1 correct answers
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
nil
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
Protected access
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
any number of parameters.
Note: This Question is unanswered, help us to find answer for this one
Based on your analysis of the above code. find out the output generated by the following lines.
let b1 = abc([9,-7,3,110,4,721)
print("number: \(b1.x), \(b1.y)")
Correct Answer:
number: -21, 330
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
Both a and b
Note: This Question is unanswered, help us to find answer for this one
What will be the output of the following code?
class a1 {
func cn10
{
for var a = 9; a >=1; --a {
for var b = 9; b >= 0; --b{
if b%2==a/2 [
print((b%4),terminator: "“)
}
}
print("")
}}}
lets = a1()
s.cn1()
Correct Answer:
13131 13131 02020
Note: This Question is unanswered, help us to find answer for this one
What will be the output of the given Apple Swift code?
var nm = 5.0
class abc[
var x = 0.0
var y: String [
return "\(nm)"
]
func kp0[
println("\(n m)")
1}
let s=abc()
println(s.kp0)
class sd1: abc[
var hB = false
func k1(){
let i = abc();
println("\(i.y)")
let be = sd1()
bc.hB = true
println("\(bc.y)")
println(i.kp())
]}
class Tn: abc[
var nm=15.0
override func kp0[
println(15.0)
]}
let tr = Tn0
tr.kp0
Correct Answer:
5.0 15.0
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
must have at least one designated initializer.
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
!
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
Unowned references
Note: This Question is unanswered, help us to find answer for this one
What will be the output of the following Apple Swift code?
enum Abc [
case Mark
case John
case Andrew
case Lucy
case June
case Kate
]
enum Class [
case First. Second. Third. Fourth. Fifth. Sixth. Seventh
1
var n1 = Abc.Lucy
n1 = .John
print(n1)
let sp = Class.Sixth
sp = .Third
switch sp {
case .Third:
print("Perrnitted to the cricket ground")
default:
print("Not Permitted to the cricket ground")
]
Correct Answer:
Code will give compilation error.
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
_ (Underscore)
Note: This Question is unanswered, help us to find answer for this one
Based on your analysis of the following Apple Swift code, identify from the given options the code that will generate compilation error when executed.
func abc
let a1 = a
a = b
b = a1
print("\(a) \(b)")
}
Correct Answer:
var z =
Note: This Question is unanswered, help us to find answer for this one
Analyze the following Apple Swift code and select its correct output from the given options.
struct a1 [
var x = 0.0, y = 0.0
}
struct b1 {
var w = 0.0. h = 0.0
}
struct Rt{
var n1 = a1()
var 51 = b1()
var c1: a1 {
getl
let cX = n1.x + (sI.w / 2)
let CY = n1.y -|- (s1.h / 2)
return a1(x: cX. y: cY)
}
set(cc) [
n1.x = cc.x - (s1.w ‘36 4)+2.5
n1.y = my - (sl.h % 4)+2.5
I I I
var rr = Rt(n1: a1(x: 0.0, y: 0.0),
$1: b1(w: 10.0, h: 10.0))
let isc = rr.c1
rr.c1 = a1(x: 16.0, y: 16.0)
print("\(rr.n1.x), \(rr.n1.y)")
Correct Answer:
16.5.16.5
Note: This Question is unanswered, help us to find answer for this one
What will be the output of the last line of the given Apple Swift code?
let a=4
print(a&+0)
print(a&-O)
print(a&0)
print(a<<1)
print(a>>1)
print(a<<2)
Correct Answer:
16
Note: This Question is unanswered, help us to find answer for this one
Analyze the Apple Swift code given in Image 1, and choose its correct output from Image
Correct Answer:
(i)
(ii)
Note: This question has more than 1 correct answers
Note: This Question is unanswered, help us to find answer for this one
Which of the following statements are valid regarding an assignment operator in Apple Swift?
1. let b=10
2. let (a,b) = (2, 3)
3. if a = b { )
Correct Answer:
Only1 and 2
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
In-out parameters
Note: This Question is unanswered, help us to find answer for this one
What will be the output of the following code?
class 81 (
func cn10
l
for var a = 9; a >= 1; --a[
for var b = 9; b >= 0; --b[
if b%2==a/2 [
print((b%4).terminator: "")
I
I
print("")
III
let s = a10
s.cn10
Correct Answer:
13131 13131 02020
Note: This Question is unanswered, help us to find answer for this one
Choose True or False.
In Apple Swift, structures are reference types, whereas classes are value types.
Correct Answer:
False
Note: This Question is unanswered, help us to find answer for this one
How many times will the following Apple Swift code print the word "green"?
for p in 21...34[
if p%2==1[
var a = "red"
var b: String?
var c = b ?? a
print( c)
}
else if p%3==2{
let a = "green"
let e = "red"
var f = e ?? a
print(f)
}
else(
var g = "green"
var h: String?
var k = h ?? g
print(k)
}
}
Correct Answer:
5
Note: This Question is unanswered, help us to find answer for this one
What will be the output of the following code?
func abc(p: Double...) -> Double {
var sm: Double = O
for number in p[
sm += number
I
return sm I Double{p.count)
I
print(abc(6, 7.25, 16.75))
Correct Answer:
10.0
Note: This Question is unanswered, help us to find answer for this one
What will be the output of the following Apple Swift code?
func abc(param1: String) -> lnt[
print(param1)
return param1.characters.count
}
func xyz(param1: String) [
abc(paramI)
}
xyz.("John Smith")
Correct Answer:
10
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
===
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
All the classes in Apple Swift are inherited from a universal base class.
Note: This Question is unanswered, help us to find answer for this one
What will be the output of the given Apple Swift code?
let a;zUlnt8 = 0b11101111
let sz;lnt8 = 0b00110011
let c=a&b
print(c)
Correct Answer:
35
Note: This Question is unanswered, help us to find answer for this one
In Apple Swift, which of the given statements is correct about initializers?
1. Failable and non-failable initializers can be defined with the same name and parameter types
2. No value can be returned by initializers.
3. A failable initializer cannot delegate to a non-failable initializer.
Correct Answer:
Only 2
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
Neither willset nor didset observer is called.
Note: This Question is unanswered, help us to find answer for this one
In Apple Swift, which of the following parameters can be used in a closure expression?
1. Constant parameters
2. Variable parameters
3. Inout parameters
4. Variadic parameters
5. Tuple parameters
Correct Answer:
All of the given parameters can be used in a closure expression.
Note: This Question is unanswered, help us to find answer for this one
Which of the following statements are incorrect regarding closures in Apple Swift?
1. In Apple Swift, a closure can capture all the references to variables from the surrounding context in which it is defined, but cannot capture references to constants.
2. A nested function is a closure that has a name but it cannot capture any value from its enclosing function.
3. A global function is a closure that has a name and does not capture any value.
Correct Answer:
Only1 and 2
Note: This Question is unanswered, help us to find answer for this one
Swift MCQs | Topic-wise