Olete.in
Articles
Mock Tests
🧪 Swift (programming language) MCQ Quiz Hub
Swift Multiple Choice Questions and Answers Set 1
Choose a topic to test your knowledge and improve your Swift (programming language) skills
1. How can we prioritize the usability of the demand Process?
Firstly, think like a user while designing the UX
Consider all the situations that prove to be useful while promoting an App
Continue to work on the utility of the App, even after the launch
All of the above
2. What are the features of Swift Programming?
Arrays and integers are checked for overflow
Switch function can be used instead of using “if” statement
It eliminates the classes that are in an unsafe mode
All of the above
3. The expression that creates a closure in Swift is called ____ in other languages it is also called a Lambda or Anonymous Function.
Parameter
Closure Expression
Defined
Control
4. What does the question mark (?) indicate A particular property is
Necessary wrong
Missing
Optionalcorrect
Changed
5. What are the common execution states in iOS?
Not runningwrong
Inactive
Active
All of the above
6. What are the advantages of swift?
Much faster than other languages B.
Supports pattern matching
Type-safe language
All of the above mentioned
7. What statement can be used to stop the execution of a loop, if, or switch statement?
Stop
Execute
Damper
Break
8. How many types of integers are in Swift?
1
2
3
4
9. What are the disadvantages of Swift?
Poor interoperability with third-party tools and IDEs
Lack of support for earlier iOS versions
Both of these
None of These
10. Which of the following is not a literals in swift?
Binary Literals
Quad Literals
Hexadecimal Literals
Decimal Literals
11. Numbers with decimal values or fractional components are called?
A. decimal number
integer number
floating numbers
All of the above
12. Which of the following features of Swift programming language?
Swift is very easy to learn and precise to use
Automatic memory management
Swift follows Objective-C like syntax
All of the above
13. In Swift programming language, single-line comments are started with ___________?
single slashes
double slashes
asterisk
hash
14. In Swift programming language, single-line comments are started with ___________? A. single slashes B. double slashes C. asterisk D. hash
single slashes
double slashes
asterisk
hash
15. ___________ is a process of querying and calling properties
A. Lazy Chaining
Swift Chaining
Optional Chaining
All of the mentioned
16. How many types of classes in Inheritance in Swift?
1
2
3
4
17. How many varieties of collection types in Swift?
2
3
4
5
18. Which Of The Following Is Incorrect Data Type In SWIFT ?
UInt
Double
Char
Optional
19. Which Of The Following Is Incorrect Value Type Of The Swift?
Double
Character
Enum
Class
20. The class which inherits the properties from other class is called child class or sub class
TRUE
FALSE
Can be true or false
Can not say
21. What are the characteristics of Switch in Swift?
It supports any kind of data, and not only synchronize but also checks for equality
When a case is matched in switch, the program exits from the switch case and does not continue checking the next cases. So you don’t need to explicitly break out the switch at the end of case
switch statement must be exhaustive, which means that you have to cover all possible values for your variable
All of the above
22. How do you declare an Iboutlet property?
IBOutlet var button: UIButton
var button: UIButton(IBOutlet)
var button: UIButtonoutlet
None of the mentioned
23. What are the features of Swift Programming?
It eliminates entire classes of unsafe code
Variables are always initialized before use
Arrays and integers are checked for overflow
All of these
24. What are the control transfer statements used in Swift?
Continue
Break
Fallthrough
All of these
25. What are the advantages of Swift?
Swift is safe
Swift is fast
Swift is open source
All of the above
26. What's are the new features in Swift 4.0?
aster, easier to use Strings that retain Unicode correctness
Smart key paths for type-safe, efficient, extensible key-value coding for Swift types
Added some enhancements to creating a dictionary and Set types
All of the above
27. What type of integer is denoted by "Int8"?
Open
Signed
Unsigned
Close
28. Given : var stringValue:String = “Justin Gif”. What is the result of stringValue = nil?
stringValue == nil
stringValue == “Justin Gif”
the compiler won't allow it
None
29. What are the collection types in Swift?
Dictionary and array
Array and library
Dictionary and library
Library, dictionary and array
30. Swift is which type of language?
scripting language
object-oriented programming language C. D.
type-safe language
All of the above
31. Choose all correct statements. S1: Swift was developed by Apple Inc S2: Swift has file name extension as .swift S3: Swift is an alternative to the Objective-C language
S1 and S2
S1 and S3
S2 and S3
S1, S2 and S3
32. Which among the following is not an Swift feature?
Tuples
Built in error handling
Generics
None of the above
33. What is the file extension for Swift programs?
.s
.sw
.swift
.sp
34. How to compile and run a script in one step?
$ swift filename.swift
$ swiftc filename
$ swiftc filename.swift
$ swift filename.s
35. How to compile a script?
$ swift filename.swift
$ swiftc filename
$ swiftc filename.swift
$ swift filename.s
36. Which command is used to get the current version of swift?
$ swift -version
$ swift --version
$ swift --v
$ swift --currentversion
37. Which is a valid variable name in Swift?
Has unicode characters
Has whitespace
Has Mathematical Symbols
Has arrows
38. Which among the following is a characteristic of Lazy Stored Procedures?
Have values that are not calculated until first accessed
lazy property is declared with lazy
Lazy stored properties must be declared with var
All of the above
39. Choose the correct Statements: S1: computed properties are built with a getter and a setter. S2: computed properties are always variables and cant be constants. S3: computed properties store something on an object and affect its memory.
S1 and S2
S1 and S3
S2 and S3
S1, S2 and S3
40. Which is not a property of type properties in Swift?
Type properties are properties on the type itself, not on the instance
type property is declared with static keyword
type property can be both stored or computed properties
type property is declared with type keyword
41. The built-in numeric types in Swift
Int4
Integer
UInt
Float16
42. Which symbol is used to separate digits in numeric literals
Underscore (_)
Dash(-)
Dot(.)
Rounded Brackets()
43. Choose the correct evaluated statement
round(-3.500) = -3
ceil(-3.999) = -3
floor(-3.001) = -3
Int(-3.999) = -4
44. The supported architecture for round, ceil and floor in Swift is/are
32 bit architecture
64 bit architecture
Both 32 and 64 bit architecture
None of the above
45. What is the general form of Random number generation in Swift?
let number = min + arc4random_uniform(max + min + 1)
let number = min + arc4random_uniform(max , min + 1)
let number = min + arc4random_uniform(max - min - 1)
let number = min + arc4random_uniform(max - min + 1)
46. Which among the following throws runtime error in Swift?
Int8(-128) B Int8(128)
Int(-0.1)
Int(-0.1)
Int8(-2)
47. Which special character doesn’t require escape sequence in order to use them in string literals?
the null character
a vertical tab
a double quote
dollar character
48. Which among the following is not true with respect to concatenation of strings in Swift?
Concatenate strings with the + operator to produce a new string
Can append a single character to a mutable String
Can append multiple characters to a mutable String
concatenation of strings is possible using += only not by using append method.
49. Which statements evaluates to true while checking the equal strings in swift?
"abc" == "def"
"abc" == "ABC"
"abc" == "abc"
"abc" ==="def"
50. Which method is used to check for prefix in Swift?
hasPrefix
isPrefix
isPart
has
51. Which method is used in String Iteration in Swift?
index(after:)
index.successor()
index.next()
index.forward()
52. Which among the following operations are valid with respect to Strings in Swift? let string = "Super Power" S1: string[2] S2: string.characters[2]
S1 only
S2 only
Both S1 and S2
Neither S1 nor S2
53. Choose the correct expression
Int("123") returns error
Int("hello") returns nil
Int("10", radix: 2) returns 10 of Int type
Double("hello") returns hello
54. How to conver the given String to uppercase in Swift? Given let string = "HhEeLlLlOo"
string.uppercased()
string.upper()
string.uppercase()
string.toUppercase()
55. Which are the Boolean Logical Operators used in Swift?
OR(||)
XOR(^^)
negate(~)
AND(&)
56. Which operator is used to negate a Bool in Swift?
!
~
NOT
!=
57. Which type are arrays in Swift?
object
value
string
only immutable
58. Which among the following array declarations is invalid?
var arrayOfStrings: [String] = []
let arrayOfUInt8s: [UInt8] = [2, 6, 8]
var arrayOfStrings = Array<String>()
var arrayOfStrings = [String]
59. Which of the following are supported by swift with respect to arrays?
Empty arrays
Arrays with repeated values
Multi-dimensional arrays
All of the above
60. How to define an array with repeated values?
let arrayOfStrings = Array(repeat: "Swift", 4)
let arrayOfStrings = Array(repeat: "Swift",count: 4)
let arrayOfStrings = Array(repeating: "Swift",count: 4)
repeated values not supported
61. Which method is used to extract values of a given type from an Array in Swift?
flatMap
extractMap
getValues
fetchValues
62. How to filter out nil from an Array transformation?
extractMap
filterMap
valueMap
flatMap
63. In the array color, how to remove "green" without knowing its index var color = ["red", "blue", "green", "yellow", "black"]
color.remove("green")
color.remove(at:2)
color.remove("2")
color.filter("green")
64. Which among the following is false with respect to map in Swift?
used for transforming an array of A to array of B
Changes the type of array
iterates through array
populates a new array with the transformed elements
65. Which method is used to compare two arrays in swift?
compare
check
zip
reduce
66. Which of following array operations supported by Swift?
Sorting an Array
Grouping Array values
Finding the minimum or maximum element with a custom ordering
All of the above
67. Which of following methods are valid in Array operations in Swift? Given: var helloArray:[Int] = [1,2,3,4,5] S1: helloArray.indexOf(2) S2: helloArray.first S3: helloArray.min() S4: helloArray.append(6)
S1,S2 and S3
S1,S3 and S4
S2,S2 and S4
S1,S2,S3 and S4
68. Which among the following is the feature of tuple in Swift?
A tuple type is a comma-separated list of types, enclosed in parentheses.
The values within a tuple can be of any type
Tuples can be decomposed into individual variables
All of the above
69. Which among the following cant be done with respect to tuples in swift?
return from functions
use of typealias keyword to name the tuple type
swap the tuple values
Sort the tuple values
70. How to swap the given tuples in swift? var a = 0 var b = 1
(a, b) = (b, a)
a.swap(b)
swap(a,b)
(a)=(b)
71. Which among the following is true with respect to Enum in Swift? S1: Enum cases can contain one or more associated values. S2: Enums can be recursive S3: Enums can have custom init methods S4: Enums can be nested
S1,S2 and S3
S1,S3 and S4
S1,S2 and S4
S1,S2, S3 and S4
72. Which keyword makes the enum store its payload with a layer of indirection in Swift?
indirect
payload
inline
raw
73. Choose the correct statements
Enums cant have custom init methods
Enum can be created using rawValue
Enums without any specific type expose the rawValue property
Enums without payloads cant have raw values of any literal type:
74. How to get enum value's corresponding raw value?
.rawValue
raw
.value
.getRawValue
75. What doe the hash value of specific enum return?
index of the enum starting from one
index of the enum starting from zero
last index
difference of first and last index of the enum
Submit