Swift Programming Quiz

Swift Programming Quiz Question and Answers

Swift language was developed by __________

  • Facebook
  • Apple
  • Microsoft
  • Google

Swift is an open-source language. True or False?

  • True
  • False

Swift can be used for developing apps for Linux. True or False?

  • True (ans)
  • False

Swift is a multi-paradigm language. True or False?

  • True
  • False

Swift Playground app is a/an ___________

  • iPad Game app
  • Travel app
  • iPad app to learn Swift
  • iPad Utility app

Memory Management in Swift is done by _________.

  • Automatic Reference Counting (ARC)
  • Manual
  • None of the options
  • Garbage Collector

A guard statement always has an else clause. True or False?

  • True
  • False

In Swift for switch statement, the default case appears at ________.

  • At first
  • In the middle
  • Always last or end
  • Anywhere

Which of the following statements is correct?

  • var name: = "Tom"
  • var name = “Tom”
  • text name: = "Tom"
  • string name = "Tom"

In swift programming language a variable is defined using ___________

  • variable
  • var
  • let
  • String

Is var keyword is used to declare constants in Swift language? True or False?

  • True
  • False

The return type of a function can be made as optional. True or False?

  • True (ans)
  • False

What would be the return type of a function, if the return type is not defined?

  • None
  • Empty Tuple
  • Nil
  • None of the options

Multiple types of data can be stored in an array. True or False?

  • True
  • False

Every Swift function has its own type. True or False?

  • True
  • False

Inferential statistics is used in __________ datasets.

  • Population
  • Sample
  • All the Options

Which keyword is used to define a function in Swift?

  • fun
  • function
  • func
  • None of the options

In Swift, it is possible to return multiple values from a function.

  • True
  • False

It is possible to define function as a return value for a Swift function.

  • True
  • False

The number of items in a dictionary can be found by using ________

  • number
  • None of the options
  • length
  • count

print("Hello, World!", "Happy Learning ") What will be the output of this code?

  • Compilation Error
  • Hello, World! Happy Learning
  • None of the options
  • Runtime Error

Let (x, y) = (1, 2) statement assigns x to 1 and y to 2.

  • True
  • False

var fruits = ["Apple", "Orange", "Apple"] print(fruits) What would be the output of this code?

  • ["Orange", "Apple"]
  • ["Apple", "Orange", "Apple"]
  • ["Orange", "Apple", "Apple"]
  • None of the options

for value in 1...3 { print(value) } What will be the output of this code snippet?

  • None of the options
  • 1 2 3
  • 1 2
  • 1 3

for value in 1..<3 { print(value) } What will be the output of this code snippet?

  • 1 2
  • 1 3
  • 1 2 3
  • None of the options

3 != 2 What will be the output of this statement?

  • True
  • False

var array = String array[0] = ""Tom"" print (array) What would be the output of this code?

  • Nil
  • Run time Error
  • ["Tom"]
  • None of the options

var name: String? name = "Tom" print(name) What will be the output of this code?

  • Tom
  • Nil
  • Optional("Tom")
  • None of the options

var array = ["Tom"] var name = array[0] print (name) What would be the output of this code?

  • Compilation Error
  • Nil
  • Tom
  • None of the options

var name: String? let newName = name! print(newName) What will be the output of this code?

  • Nil
  • Optional
  • Runtime Error
  • None of the options

var name: String? print(name) What will be the output of this code?

  • None of the options
  • Compilation Error
  • Runtime Error
  • Nil

var array = ["Tom"] var name = array[10] print (name) What would be the output of this code?

  • Nil
  • Run time Error
  • None of the options
  • Tom

var array = String array[10] = "Tom" print (array) What would be the output of this code?

  • None of the options
  • Run time Error
  • Nil
  • Tom

var fruits:Set = ["Apple", "Orange", "Apple"] print(fruits) What would be the output of this code?

  • None of the options
  • ["Orange", "Apple"]
  • ["Orange", "Apple", "Apple"]
  • ["Orange"]

var name = (1, "Tom") print (name.0) print (name.1) What will be the output of this code?

  • Compilation Error
  • 1 Tom
  • Runtime Error
  • None of the options

(4, "dog") == (4, "dog") What will be the output of this statement?

  • True
  • False

let name = "John" print (name) name = "Doe" print (name) What will be the output of this code?

  • Compilation error (ans)
  • Doe
  • John Doe
  • None of the options