Swift (iOs) MCQs with answers Page - 20

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

Q. Which method is used to convert an array into a string?

  • (A) join()
  • (B) joined()
  • (C) concat()
  • (D) combine()

R

Ravina • 3.96K Points
Extraordinary

Q. Which of these types is a reference type?

  • (A) Struct
  • (B) Tuple
  • (C) Enum
  • (D) Class

R

Ravina • 3.96K Points
Extraordinary

Q. Which keyword is used to define an initializer?

  • (A) init
  • (B) constructor
  • (C) initialize
  • (D) create

R

Ravina • 3.96K Points
Extraordinary

Q. Which Swift keyword is used to inherit from another class?

  • (A) :
  • (B) inherits
  • (C) extends
  • (D) ->

R

Ravina • 3.96K Points
Extraordinary

Q. What will this code output?

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

R

Ravina • 3.96K Points
Extraordinary

Q. Which keyword is used to mark a class available only for subclassing within the module?

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

R

Ravina • 3.96K Points
Extraordinary

Q. Which function creates a random integer within a range?

  • (A) random()
  • (B) Int.random(in: 1...10)
  • (C) randInt(1, 10)
  • (D) generate()

R

Ravina • 3.96K Points
Extraordinary

Q. Which Swift structure is best suited for modeling immutable data?

  • (A) Class
  • (B) Enum
  • (C) Struct
  • (D) AnyObject