Swift (iOs) MCQs with answers Page - 3

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 of the following is a valid way to declare an array in Swift?

  • (A) var arr = Array<Int>()
  • (B) int[] arr = new int[]
  • (C) array arr = []
  • (D) arr = list()

R

Ravina • 3.59K Points
Extraordinary

Q. What will this Swift code output?

Code:
let value = true
print(!value)
  • (A) true
  • (B) false
  • (C) nil
  • (D) 1

R

Ravina • 3.59K Points
Extraordinary

Q. How do you define a dictionary in Swift?

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

R

Ravina • 3.59K Points
Extraordinary

Q. What will the following Swift code print?

Code:
let x = 10
let y = 20
print(x < y)
  • (A) true
  • (B) false
  • (C) nil
  • (D) 0

R

Ravina • 3.59K Points
Extraordinary

Q. What is the type of a tuple declared as `let point = (2, 3)`?

  • (A) (Int, Int)
  • (B) Array<Int>
  • (C) Set<Int>
  • (D) Dictionary

R

Ravina • 3.59K Points
Extraordinary

Q. How do you create a multiline string in Swift?

  • (A) Using triple single quotes ''' '''
  • (B) Using + for each line
  • (C) Using triple double quotes """ """
  • (D) Using backticks

R

Ravina • 3.59K Points
Extraordinary

Q. What will this Swift code output?

Code:
let numbers = [1, 2, 3]
print(numbers.count)
  • (A) 3
  • (B) 2
  • (C) 1
  • (D) 0

R

Ravina • 3.59K Points
Extraordinary

Q. Which of the following is true about Swift 'struct'?

  • (A) Structs are reference types
  • (B) Structs support inheritance
  • (C) Structs are value types
  • (D) Structs must be declared as final

R

Ravina • 3.59K Points
Extraordinary

Q. Which operator is used to concatenate strings in Swift?

  • (A) *
  • (B) &
  • (C) +
  • (D) #

R

Ravina • 3.59K Points
Extraordinary

Q. How do you create a range from 1 to 5 in Swift?

  • (A) 1..<5
  • (B) 1...5
  • (C) [1-5]
  • (D) {1,2,3,4,5}

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