Swift (iOs) MCQs with answers Page - 11

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 • 828.03K Points
Coach

Q. Which Swift keyword is used to declare a constant?

  • (A) const
  • (B) let
  • (C) final
  • (D) immutable

A

Admin • 828.03K Points
Coach

Q. What is the result of the expression `true && false || true`?

  • (A) false
  • (B) true
  • (C) Error
  • (D) nil

A

Admin • 828.03K Points
Coach

Q. What is the result of `Double("abc")` in Swift?

  • (A) 0.0
  • (B) abc
  • (C) nil
  • (D) Error

A

Admin • 828.03K Points
Coach

Q. Which of the following is the correct way to declare an optional integer?

  • (A) var age = ?Int
  • (B) var age: Int?
  • (C) var age: Optional<Int>
  • (D) Both 2 and 3

A

Admin • 828.03K Points
Coach

Q. What will the following Swift code print?

Code:
let name = "Swift"
print(name.lowercased())
  • (A) SWIFT
  • (B) swift
  • (C) Swift
  • (D) sWIFT

A

Admin • 828.03K Points
Coach

Q. Which of these is a correct way to create a set in Swift?

  • (A) var mySet = Set()
  • (B) var mySet = Set<Int>()
  • (C) var mySet = [Int]()
  • (D) var mySet = Dictionary()

A

Admin • 828.03K Points
Coach

Q. What is the purpose of `map` in Swift?

  • (A) To filter values in a list
  • (B) To transform values in a list
  • (C) To reduce a list to one value
  • (D) To sort the list

A

Admin • 828.03K Points
Coach

Q. What will this Swift code output?

Code:
let a = 3
let b = 3.0
print(Double(a) == b)
  • (A) true
  • (B) false
  • (C) Error
  • (D) nil

A

Admin • 828.03K Points
Coach

Q. Which keyword is used to stop a loop early?

  • (A) stop
  • (B) end
  • (C) break
  • (D) exit

A

Admin • 828.03K Points
Coach

Q. What does `lazy` mean in property declaration?

  • (A) It can never be initialized
  • (B) It is loaded at compile time
  • (C) It is initialized only when used
  • (D) It cannot be used with constants

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