Swift Operators and Expressions Quiz

Test your knowledge of operators and expressions in Swift.

1. 
Which operator is used to determine if two values are not equal in Swift?

2. 
How does the range operator x ..< y differ from x…y?

3. 
What would the expression x = x * 2 be simplified to using a compound assignment operator?

4. 
What does the basic assignment operator (=) do in Swift?

5. 
Which Swift operator is used to perform subtraction?

6. 
What is the equivalent of the expression x = x + y using compound assignment?

7. 
How does the ternary operator in Swift work?

8. 
What is the purpose of the bitwise left shift operator in Swift?

9. 
What does the bitwise AND operator (&) do?

10. 
What is the effect of the unary minus operator (-) in Swift?

11. 
What does the bitwise XOR operator (^) do?

12. 
Which operator is used to provide a default value if an optional is nil?

13. 
What is the result of 10101011 >> 1 in binary?

14. 
How does the logical AND operator (&&) function in Swift?

15. 
Which operator is used to check if one value is greater than or equal to another?

16. 
How does the bitwise NOT operator (~) affect a number?

17. 
What is the result of the expression 2…5 in Swift?

18. 
What does the expression x = y & z compute in Swift?

19. 
How does the logical OR operator (||) operate?

20. 
What is the function of the bitwise XOR operator (^)?

Congratulations on completing the Swift Operators and Expressions Quiz.

Click the Submit button to review your results.

Enter your email address below if you would like to receive a copy of your test results.


Categories