Swift (iOs) MCQs with answers Page - 8

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. What is the result of this expression: `true || false && false`?

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

A

Admin • 828.03K Points
Coach

Q. What type of value does `Bool.random()` return?

  • (A) true
  • (B) false
  • (C) Random Bool value
  • (D) Int

A

Admin • 828.03K Points
Coach

Q. What is the type of `let a = 3.14` in Swift?

  • (A) Float
  • (B) Double
  • (C) Int
  • (D) Decimal

A

Admin • 828.03K Points
Coach

Q. How do you make a property read-only in Swift?

  • (A) By using let
  • (B) By using private
  • (C) By using get-only computed property
  • (D) By using final

A

Admin • 828.03K Points
Coach

Q. What is the purpose of the `didSet` observer in Swift?

  • (A) To observe a property before it's set
  • (B) To call a function when a class is initialized
  • (C) To run code after a property’s value is changed
  • (D) To override a property

A

Admin • 828.03K Points
Coach

Q. Which of the following is a correct computed property?

  • (A) var name = "John"
  • (B) var age: Int = 25
  • (C) var area: Int { return width * height }
  • (D) let value = ()

A

Admin • 828.03K Points
Coach

Q. What does the nil coalescing operator `??` do?

  • (A) Returns true if both are nil
  • (B) Unwraps optional or provides default value
  • (C) Checks for nil only
  • (D) Replaces nil with 0

A

Admin • 828.03K Points
Coach

Q. Which Swift keyword is used to define a fallback in case of failure?

  • (A) guard
  • (B) throw
  • (C) catch
  • (D) do

A

Admin • 828.03K Points
Coach

Q. What will the following code print?

Code:
let list = ["a", "b", "c"]
if list.contains("b") {
 print("Found") }
  • (A) true
  • (B) Found
  • (C) false
  • (D) Error

A

Admin • 828.03K Points
Coach

Q. What will this Swift code output?

Code:
let a = 7
let b = 3
print(a % b)
  • (A) 2
  • (B) 1
  • (C) 0
  • (D) 4

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