Swift (iOs) MCQs with answers Page - 19

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

R

Ravina • 3.96K Points
Extraordinary

Q. Which type of loop is guaranteed to run at least once?

  • (A) for-in
  • (B) while
  • (C) repeat-while
  • (D) forEach

R

Ravina • 3.96K Points
Extraordinary

Q. What is the type of a Swift closure that takes no parameters and returns nothing?

  • (A) () -> Void
  • (B) Void -> Void
  • (C) () -> ()
  • (D) None -> Void

R

Ravina • 3.96K Points
Extraordinary

Q. What does the `Set` type ensure in Swift?

  • (A) Sorted elements
  • (B) Duplicate elements
  • (C) Ordered elements
  • (D) Unique elements

R

Ravina • 3.96K Points
Extraordinary

Q. Which keyword is used to create a protocol extension?

  • (A) extend
  • (B) extension
  • (C) add
  • (D) protocol+

R

Ravina • 3.96K Points
Extraordinary

Q. How is a range from 1 to 5 (inclusive) written in Swift?

  • (A) 1..<5
  • (B) 1...5
  • (C) [1...5]
  • (D) 1 to 5

R

Ravina • 3.96K Points
Extraordinary

Q. Which operator is used to define nil-coalescing behavior?

  • (A) !
  • (B) ?.
  • (C) ??
  • (D) :?

R

Ravina • 3.96K Points
Extraordinary

Q. What is `Codable` in Swift?

  • (A) A database protocol
  • (B) A user interface element
  • (C) A combination of Encodable and Decodable
  • (D) A custom enum

R

Ravina • 3.96K Points
Extraordinary

Q. What will `print("\u{1F600}")` output?

  • (A) u{1F600}
  • (B) ☺
  • (C) ?
  • (D) Error

R

Ravina • 3.96K Points
Extraordinary

Q. What is the output of `print(type(of: [1, 2, 3]))`?

  • (A) Array
  • (B) Int[]
  • (C) Array<Int>
  • (D) List<Int>

R

Ravina • 3.96K Points
Extraordinary

Q. Which of the following is NOT a collection type in Swift?

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