Swift (iOs) MCQs with answers Page - 10

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 of these is NOT a valid Swift access modifier?

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

A

Admin • 828.03K Points
Coach

Q. Which Swift collection type uses key-value pairs?

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

A

Admin • 828.03K Points
Coach

Q. How do you create a range from 1 to 4, excluding 4?

  • (A) 1 to 4
  • (B) 1...4
  • (C) 1..<4
  • (D) [1,4)

A

Admin • 828.03K Points
Coach

Q. What is the default value of a Boolean in Swift?

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

A

Admin • 828.03K Points
Coach

Q. Which of the following declares an empty dictionary?

  • (A) let dict = Dictionary<String, Int>()
  • (B) let dict = {}
  • (C) let dict = [String: Int: String]()
  • (D) let dict = [String, Int]()

A

Admin • 828.03K Points
Coach

Q. Which of these is used for method overriding in Swift?

  • (A) override
  • (B) overload
  • (C) virtual
  • (D) extends

A

Admin • 828.03K Points
Coach

Q. Which keyword is used to handle errors in Swift?

  • (A) catch
  • (B) handle
  • (C) try
  • (D) throw

A

Admin • 828.03K Points
Coach

Q. How do you define a tuple with named elements?

  • (A) let person = ("John", 25)
  • (B) let person = [name: "John", age: 25]
  • (C) let person = (name: "John", age: 25)
  • (D) let person = person(name: "John", age: 25)

A

Admin • 828.03K Points
Coach

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

  • (A) To make variables immutable
  • (B) To return values from a function
  • (C) To pass by reference
  • (D) To initialize optional values

A

Admin • 828.03K Points
Coach

Q. What does `@State` in SwiftUI signify?

  • (A) A constant value
  • (B) An immutable variable
  • (C) A property that can change and is watched by the view
  • (D) A global variable

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