Swift (iOs) MCQs with answers Page - 12

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

Q. Which of the following is true about tuples in Swift?

  • (A) Tuples can have different types
  • (B) Tuples must have the same type
  • (C) Tuples are immutable
  • (D) Tuples are classes

A

Admin • 833.24K Points
Coach

Q. Which of the following is the correct syntax for a function that throws an error?

  • (A) func test() throws -> Void
  • (B) func test() throw -> Void
  • (C) func test() throws -> Error
  • (D) func test() throw Void

A

Admin • 833.24K Points
Coach

Q. How do you provide a fallback value for an optional?

  • (A) Using ||
  • (B) Using ??
  • (C) Using ?
  • (D) Using if-else

A

Admin • 833.24K Points
Coach

Q. What does the `@available` attribute do in Swift?

  • (A) Marks a property private
  • (B) Restricts a function to certain platforms or versions
  • (C) Creates a computed property
  • (D) Specifies memory management

A

Admin • 833.24K Points
Coach

Q. Which of these statements about optionals is true?

  • (A) An optional must have a value
  • (B) Optionals cannot be nil
  • (C) Optionals can be nil or have a value
  • (D) Optionals are always unwrapped automatically

A

Admin • 833.24K Points
Coach

Q. Which of the following is a correct way to declare a computed read-only property?

  • (A) var square = side * side
  • (B) var square: Int { return side * side }
  • (C) let square = side * side
  • (D) var square() -> Int

A

Admin • 833.24K Points
Coach

Q. What does the `guard` statement do?

  • (A) Exits the current scope if the condition is false
  • (B) Continues the loop
  • (C) Skips optional binding
  • (D) Throws an error

A

Admin • 833.24K Points
Coach

Q. Which function is used to sort an array in Swift?

  • (A) sortArray()
  • (B) sorted()
  • (C) arrange()
  • (D) filter()

A

Admin • 833.24K Points
Coach

Q. Which of the following is used to check if a value is of a certain type?

  • (A) as
  • (B) is
  • (C) typeof
  • (D) instanceof

A

Admin • 833.24K Points
Coach

Q. Which keyword is used in Swift to prevent a method from being overridden?

  • (A) static
  • (B) final
  • (C) private
  • (D) sealed

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