Swift (iOs) MCQs with answers Page - 9

Here, you will find a collection of MCQ questions on Swift (iOs). Go through these questions to enhance your preparation for upcoming examinations and interviews.

To check the correct answer, simply click the View Answer button provided for each question.

Have your own questions to contribute? Click the button below to share your MCQs with others!

+ Add Question

A

Admin • 802.91K Points
Coach

Q. Which keyword makes a method or property available only to the defining class?

  • (A) internal
  • (B) public
  • (C) private
  • (D) fileprivate

A

Admin • 802.91K Points
Coach

Q. What is the result of the following code?

Code:
let result = 3 + 2 * 4
print(result)
  • (A) 20
  • (B) 14
  • (C) 11
  • (D) 13

A

Admin • 802.91K Points
Coach

Q. What is the data type of `true` in Swift?

  • (A) Int
  • (B) Bool
  • (C) String
  • (D) Character

A

Admin • 802.91K Points
Coach

Q. Which collection is unordered in Swift?

  • (A) Array
  • (B) Tuple
  • (C) Set
  • (D) Dictionary

A

Admin • 802.91K Points
Coach

Q. Which operator is used to combine conditions in Swift?

  • (A) &
  • (B) |
  • (C) &&
  • (D) ==

A

Admin • 802.91K Points
Coach

Q. What does `typealias` do in Swift?

  • (A) Creates a new class
  • (B) Defines a type for enums
  • (C) Provides an alternative name for a type
  • (D) Creates a constant

A

Admin • 802.91K Points
Coach

Q. Which of these Swift types is used for a single Unicode character?

  • (A) String
  • (B) Character
  • (C) Char
  • (D) Unicode

A

Admin • 802.91K Points
Coach

Q. How do you remove all elements from an array?

  • (A) array.clear()
  • (B) array = []
  • (C) array.empty()
  • (D) array.deleteAll()

A

Admin • 802.91K Points
Coach

Q. What is the purpose of `fatalError()` in Swift?

  • (A) To handle errors
  • (B) To throw exceptions
  • (C) To crash the program intentionally
  • (D) To log output

A

Admin • 802.91K Points
Coach

Q. What will this Swift code print?

Code:
let value = "42"
if let intValue = Int(value) {
 print(intValue * 2) }
  • (A) 84
  • (B) 42
  • (C) Error
  • (D) nil

Add MCQ in this Category

If you want to share an MCQ question in this category, it's a great idea! It will be helpful for many other students using this website.

Share Your MCQ