Swift - Constants and Variables Quiz

Topics: Declaration, Type Annotation, Naming, and Printing

Swift Quiz #01: Constants and Variables

4 mins read

1. What keyword is used to declare constants in Swift?

2. Are the below constants valid?

let 你好 = “你好世界”  
let 🐶🐮 = “dogcow”

3. What is the syntax for declaring multiple constants on a single line?

4. What is the purpose of providing a type annotation in Swift?

5. What characters are not allowed in constant and variable names?

6. How do you print the current value of a constant or variable in Swift?

7. What is the default terminator used by the `print()` function?


What is the purpose of string interpolation in Swift?
e.g print("current value of count is \(count)")

9. Is the below variable declaration valid?

var `while` = 10 

10. What happens if you try to change the value of a constant in Swift?