Swift (programming language)/Swift Multiple Choice Questions and Answers Set 1 Sample Test,Sample questions

Question:
 The class which inherits the properties from other class is called child class or sub class

1.TRUE

2.FALSE

3.Can be true or false

4.Can not say


Question:
Choose all correct statements. S1: Swift was developed by Apple Inc S2: Swift has file name extension as .swift S3: Swift is an alternative to the Objective-C language

1.S1 and S2

2.S1 and S3

3.S2 and S3

4.S1, S2 and S3


Question:
Choose the correct evaluated statement

1.round(-3.500) = -3

2.ceil(-3.999) = -3

3.floor(-3.001) = -3

4.Int(-3.999) = -4


Question:
Choose the correct expression

1.Int("123") returns error

2.Int("hello") returns nil

3.Int("10", radix: 2) returns 10 of Int type

4.Double("hello") returns hello


Question:
Choose the correct statements

1.Enums cant have custom init methods

2. Enum can be created using rawValue

3.Enums without any specific type expose the rawValue property

4.Enums without payloads cant have raw values of any literal type:


Question:
Choose the correct Statements: S1: computed properties are built with a getter and a setter. S2: computed properties are always variables and cant be constants. S3: computed properties store something on an object and affect its memory.

1.S1 and S2

2.S1 and S3

3.S2 and S3

4.S1, S2 and S3


Question:
Given : var stringValue:String = “Justin Gif”. What is the result of stringValue = nil?

1.stringValue == nil

2.stringValue == “Justin Gif”

3.the compiler won't allow it

4.None


Question:
How can we prioritize the usability of the demand Process?

1.Firstly, think like a user while designing the UX

2.Consider all the situations that prove to be useful while promoting an App

3.Continue to work on the utility of the App, even after the launch

4.All of the above


Question:
How do you declare an Iboutlet property?

1. IBOutlet var button: UIButton

2.var button: UIButton(IBOutlet)

3.var button: UIButtonoutlet

4.None of the mentioned


Question:
How many types of classes in Inheritance in Swift?

1.1

2.2

3.3

4.4


Question:
How many types of integers are in Swift?

1.1

2.2

3.3

4.4


Question:
How many varieties of collection types in Swift?

1.2

2.3

3.4

4.5


Question:
How to compile a script?

1.$ swift filename.swift

2.$ swiftc filename

3.$ swiftc filename.swift

4.$ swift filename.s


Question:
How to compile and run a script in one step?

1.$ swift filename.swift

2.$ swiftc filename

3.$ swiftc filename.swift

4.$ swift filename.s


Question:
How to conver the given String to uppercase in Swift? Given let string = "HhEeLlLlOo"

1.string.uppercased()

2. string.upper()

3.string.uppercase()

4.string.toUppercase()


Question:
How to define an array with repeated values?

1.let arrayOfStrings = Array(repeat: "Swift", 4)

2.let arrayOfStrings = Array(repeat: "Swift",count: 4)

3.let arrayOfStrings = Array(repeating: "Swift",count: 4)

4.repeated values not supported


Question:
How to filter out nil from an Array transformation?

1.extractMap

2.filterMap

3.valueMap

4. flatMap


Question:
How to get enum value's corresponding raw value?

1..rawValue

2.raw

3..value

4..getRawValue


Question:
How to swap the given tuples in swift? var a = 0 var b = 1

1.(a, b) = (b, a)

2.a.swap(b)

3.swap(a,b)

4.(a)=(b)


Question:
In Swift programming language, single-line comments are started with ___________?
A. single slashes
B. double slashes
C. asterisk
D. hash

1. single slashes

2.double slashes

3.asterisk

4.hash


Question:
In Swift programming language, single-line comments are started with ___________?

1.single slashes

2.double slashes

3.asterisk

4.hash


Question:
In the array color, how to remove "green" without knowing its index var color = ["red", "blue", "green", "yellow", "black"]

1.color.remove("green")

2.color.remove(at:2)

3.color.remove("2")

4.color.filter("green")


Question:
Numbers with decimal values or fractional components are called?

1. A. decimal number

2.integer number

3.floating numbers

4.All of the above


Question:
Swift is which type of language?

1.scripting language

2.object-oriented programming language C. D.

3.type-safe language

4.All of the above


Question:
The built-in numeric types in Swift

1.Int4

2.Integer

3.UInt

4.Float16


Question:
The expression that creates a closure in Swift is called ____ in other languages it is also called a Lambda or Anonymous Function.

1.Parameter

2.Closure Expression

3.Defined

4.Control


Question:
The supported architecture for round, ceil and floor in Swift is/are

1.32 bit architecture

2.64 bit architecture

3.Both 32 and 64 bit architecture

4.None of the above


Question:
What are the advantages of swift?

1.Much faster than other languages B.

2.Supports pattern matching

3.Type-safe language

4.All of the above mentioned


Question:
What are the advantages of Swift?

1.Swift is safe

2.Swift is fast

3.Swift is open source

4.All of the above


Question:
What are the characteristics of Switch in Swift?

1.It supports any kind of data, and not only synchronize but also checks for equality

2.When a case is matched in switch, the program exits from the switch case and does not continue checking the next cases. So you don’t need to explicitly break out the switch at the end of case

3.switch statement must be exhaustive, which means that you have to cover all possible values for your variable

4.All of the above


Question:
What are the collection types in Swift?

1.Dictionary and array

2.Array and library

3.Dictionary and library

4.Library, dictionary and array


Question:
What are the common execution states in iOS?
 

1.Not runningwrong

2.Inactive

3.Active

4.All of the above


Question:
What are the control transfer statements used in Swift?

1.Continue

2.Break

3.Fallthrough

4.All of these


Question:
What are the disadvantages of Swift?

1.Poor interoperability with third-party tools and IDEs

2.Lack of support for earlier iOS versions

3.Both of these

4.None of These


Question:
What are the features of Swift Programming?

1. It eliminates entire classes of unsafe code

2.Variables are always initialized before use

3.Arrays and integers are checked for overflow

4.All of these


Question:
What are the features of Swift Programming?

1.Arrays and integers are checked for overflow

2.Switch function can be used instead of using “if” statement

3.It eliminates the classes that are in an unsafe mode

4.All of the above


Question:
What doe the hash value of specific enum return?

1.index of the enum starting from one

2.index of the enum starting from zero

3.last index

4.difference of first and last index of the enum


Question:
What does the question mark (?) indicate A particular property is

1.Necessary wrong

2.Missing

3.Optionalcorrect

4.Changed


Question:
What is the file extension for Swift programs?

1..s

2..sw

3..swift

4..sp


Question:
What is the general form of Random number generation in Swift?

1.let number = min + arc4random_uniform(max + min + 1)

2.let number = min + arc4random_uniform(max , min + 1)

3.let number = min + arc4random_uniform(max - min - 1)

4.let number = min + arc4random_uniform(max - min + 1)


Question:
What statement can be used to stop the execution of a loop, if, or switch statement?

1.Stop

2.Execute

3.Damper

4.Break


Question:
What type of integer is denoted by "Int8"?

1.Open

2.Signed

3.Unsigned

4.Close


Question:
What's are the new features in Swift 4.0?

1.aster, easier to use Strings that retain Unicode correctness

2.Smart key paths for type-safe, efficient, extensible key-value coding for Swift types

3.Added some enhancements to creating a dictionary and Set types

4.All of the above


Question:
Which among the following array declarations is invalid?

1.var arrayOfStrings: [String] = []

2.let arrayOfUInt8s: [UInt8] = [2, 6, 8]

3.var arrayOfStrings = Array<String>()

4.var arrayOfStrings = [String]


Question:
Which among the following cant be done with respect to tuples in swift?

1.return from functions

2.use of typealias keyword to name the tuple type

3.swap the tuple values

4.Sort the tuple values


Question:
Which among the following is a characteristic of Lazy Stored Procedures?

1.Have values that are not calculated until first accessed

2.lazy property is declared with lazy

3.Lazy stored properties must be declared with var

4.All of the above


Question:
Which among the following is false with respect to map in Swift?

1.used for transforming an array of A to array of B

2.Changes the type of array

3.iterates through array

4.populates a new array with the transformed elements


Question:
Which among the following is not an Swift feature?

1.Tuples

2.Built in error handling

3.Generics

4.None of the above


Question:
Which among the following is not true with respect to concatenation of strings in Swift?

1.Concatenate strings with the + operator to produce a new string

2.Can append a single character to a mutable String

3.Can append multiple characters to a mutable String

4.concatenation of strings is possible using += only not by using append method.


Question:
Which among the following is the feature of tuple in Swift?

1.A tuple type is a comma-separated list of types, enclosed in parentheses.

2.The values within a tuple can be of any type

3. Tuples can be decomposed into individual variables

4.All of the above


Question:
Which among the following is true with respect to Enum in Swift? S1: Enum cases can contain one or more associated values. S2: Enums can be recursive S3: Enums can have custom init methods S4: Enums can be nested

1.S1,S2 and S3

2.S1,S3 and S4

3.S1,S2 and S4

4.S1,S2, S3 and S4


Question:
Which among the following operations are valid with respect to Strings in Swift? let string = "Super Power" S1: string[2] S2: string.characters[2]

1.S1 only

2.S2 only

3.Both S1 and S2

4. Neither S1 nor S2


Question:
Which among the following throws runtime error in Swift?

1.Int8(-128) B Int8(128)

2.Int(-0.1)

3.Int(-0.1)

4.Int8(-2)


Question:
Which are the Boolean Logical Operators used in Swift?

1.OR(||)

2.XOR(^^)

3.negate(~)

4.AND(&)


Question:
Which command is used to get the current version of swift?

1.$ swift -version

2.$ swift --version

3. $ swift --v

4.$ swift --currentversion


Question:
Which is a valid variable name in Swift?

1.Has unicode characters

2.Has whitespace

3.Has Mathematical Symbols

4.Has arrows


Question:
Which is not a property of type properties in Swift?

1.Type properties are properties on the type itself, not on the instance

2.type property is declared with static keyword

3.type property can be both stored or computed properties

4.type property is declared with type keyword


Question:
Which keyword makes the enum store its payload with a layer of indirection in Swift?

1.indirect

2.payload

3.inline

4.raw


Question:
Which method is used in String Iteration in Swift?

1.index(after:)

2. index.successor()

3.index.next()

4.index.forward()


Question:
Which method is used to check for prefix in Swift?

1.hasPrefix

2. isPrefix

3. isPart

4.has


Question:
Which method is used to compare two arrays in swift?

1.compare

2.check

3.zip

4.reduce


Question:
Which method is used to extract values of a given type from an Array in Swift?

1.flatMap

2.extractMap

3.getValues

4.fetchValues


Question:
Which of following array operations supported by Swift?

1.Sorting an Array

2.Grouping Array values

3.Finding the minimum or maximum element with a custom ordering

4.All of the above


Question:
Which of following methods are valid in Array operations in Swift? Given: var helloArray:[Int] = [1,2,3,4,5] S1: helloArray.indexOf(2) S2: helloArray.first S3: helloArray.min() S4: helloArray.append(6)

1.S1,S2 and S3

2.S1,S3 and S4

3.S2,S2 and S4

4.S1,S2,S3 and S4


Question:
Which of the following are supported by swift with respect to arrays?

1.Empty arrays

2.Arrays with repeated values

3.Multi-dimensional arrays

4.All of the above


Question:
Which of the following features of Swift programming language?

1.Swift is very easy to learn and precise to use

2.Automatic memory management

3.Swift follows Objective-C like syntax

4.All of the above


Question:
Which Of The Following Is Incorrect Data Type In SWIFT ?

1.UInt

2.Double

3.Char

4.Optional


Question:
Which Of The Following Is Incorrect Value Type Of The Swift?

1.Double

2.Character

3.Enum

4.Class


Question:
Which of the following is not a literals in swift?

1.Binary Literals

2.Quad Literals

3.Hexadecimal Literals

4. Decimal Literals


Question:
Which operator is used to negate a Bool in Swift?

1.!

2. ~

3.NOT

4.!=


Question:
Which special character doesn’t require escape sequence in order to use them in string literals?

1.the null character

2.a vertical tab

3.a double quote

4.dollar character


Question:
Which statements evaluates to true while checking the equal strings in swift?

1."abc" == "def"

2."abc" == "ABC"

3."abc" == "abc"

4."abc" ==="def"


Question:
Which symbol is used to separate digits in numeric literals

1.Underscore (_)

2.Dash(-)

3.Dot(.)

4.Rounded Brackets()


Question:
Which type are arrays in Swift?

1.object

2.value

3.string

4.only immutable


Question:
___________ is a process of querying and calling properties

1. A. Lazy Chaining

2.Swift Chaining

3.Optional Chaining

4.All of the mentioned


More MCQS

  1. Swift Multiple Choice Questions and Answers Set 1
  2. Swift Multiple Choice Questions and Answers Set 2
Search
Olete Team
Online Exam TestTop Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on Online Exam Testwebsite is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!