Swift (iOs) MCQs with answers Page - 2

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.59K Points
Extraordinary

Q. Which Swift statement is used to exit a loop early?

  • (A) exit
  • (B) continue
  • (C) return
  • (D) break

R

Ravina • 3.59K Points
Extraordinary

Q. What does this Swift code print?

Code:
let a = 2
let b = 3
print(a == b)
  • (A) true
  • (B) false
  • (C) 2
  • (D) 3

R

Ravina • 3.59K Points
Extraordinary

Q. What is the output of the following code?

Code:
var name: String? = "Swift"
if let unwrappedName = name {
    print(unwrappedName)
}
  • (A) Optional("Swift")
  • (B) Swift
  • (C) unwrappedName
  • (D) nil

R

Ravina • 3.59K Points
Extraordinary

Q. Which keyword is used for declaring a class in Swift?

  • (A) object
  • (B) class
  • (C) struct
  • (D) type

R

Ravina • 3.59K Points
Extraordinary

Q. Which Swift keyword is used to handle errors?

  • (A) catch
  • (B) try
  • (C) error
  • (D) rescue

R

Ravina • 3.59K Points
Extraordinary

Q. What will this code print?

Code:
let x = 4.5
let y = 2
print(x * Double(y))
  • (A) 9.0
  • (B) 9
  • (C) 6.5
  • (D) Error

R

Ravina • 3.59K Points
Extraordinary

Q. Which type is used to represent decimal values in Swift?

  • (A) Int
  • (B) Double
  • (C) Bool
  • (D) Character

R

Ravina • 3.59K Points
Extraordinary

Q. Which keyword is used to declare a structure in Swift?

  • (A) class
  • (B) struct
  • (C) object
  • (D) model

R

Ravina • 3.59K Points
Extraordinary

Q. What will be the output of this code?

Code:
let score = 85
let result = score >= 50 ? "Pass" : "Fail"
print(result)
  • (A) Pass
  • (B) Fail
  • (C) Error
  • (D) score

R

Ravina • 3.59K Points
Extraordinary

Q. What is the purpose of the `guard` statement in Swift?

  • (A) To loop through collections
  • (B) To ensure a condition is true, or exit early
  • (C) To define a function
  • (D) To catch an exception

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