Swift Fundamentals - Integer, Float and Boolean Quiz

Topics : Integer, Int, UInt, Float, Boolean, and Type Alias

Swift Quiz #02 Fundamentals - Integer, Float, and Boolean

5 mins read

1. What is the maximum value that can be stored in an Int8 in Swift?

2. Which type should be used in Swift to store a large floating-point number with high precision?

3. What is the output of the following code snippet?

 let number: Int = 42
let result = number % 7
print(result)

4. Which of the following is a valid type alias declaration in Swift?

5. What is the size of the Int type in Swift on a 64-bit platform?

6. Which of the following is an example of a hexadecimal numeric literal in Swift?

7. What is the type of the variable "maxAmplitudeFound" in the following code?

 typealias AudioSample = UInt16
let maxAmplitudeFound = AudioSample.min

8. Which of the following is the correct way to access the maximum value of an Int32 in Swift?

9. What is the output of the following code snippet?

 let x: Double = 1.5
let y: Int = 2
let result = x + Double(y)
print(result)

10. Which of the following is the correct way to declare a variable in Swift without assigning an initial value?