Swift MCQ Test: Swift MCQs - Practice Questions
1. What is the purpose of Swift's 'defer' statement?
2. In Swift, how do you declare a custom error type conforming to 'Error' protocol?
3. Explain the use of Swift's 'lazy' keyword.
4. How is 'protocol-oriented programming' emphasized in Swift?
5. Explain the concept of 'typealias' in Swift.
6. What are the benefits of using Swift Optionals?
7. Which Swift keyword is used to indicate the absence of a value?
8. Explain the concept of Swift's 'Set' type.
9. Which Swift keyword is used to start a loop?
10. What is the correct way to check if two strings are not equal in Swift?
11. What is the purpose of Swift's 'Any' and 'AnyObject' types?
12. How can you define a default parameter value in a Swift function?
13. What is the correct way to create a range of numbers from 1 to 5 in Swift?
14. What is the 'nil coalescing operator' (??) used for in Swift?
15. How does Swift handle memory management?
16. How does Swift handle memory management for reference types?
17. Explain Swift's 'map', 'filter', and 'reduce' functions.
18. In Swift, what does the 'lazy' keyword indicate when used before a property?
19. What is the correct way to concatenate two strings in Swift?
20. What are generics in Swift?
21. What is the correct syntax for declaring a function in Swift?
22. Which keyword is used to declare a constant in Swift?
23. Which Swift data type is used to store whole numbers?
24. Which Swift keyword is used to check multiple conditions in an 'if' statement?
25. What is the purpose of the Swift 'enum' type?
26. What is the purpose of the 'map' function in Swift?
27. How can you handle errors in Swift?
28. How can you achieve thread safety in Swift?
29. In Swift, how do you declare a variable without assigning a value?
30. How do you declare a property as 'weak' in Swift?
31. What is the purpose of the 'if' statement in Swift?
32. What is the purpose of the 'return' keyword in a Swift function?
33. Explain the concept of protocol-oriented programming in Swift.
34. What is the purpose of the 'unowned' keyword in Swift?
35. What is the purpose of Swift's 'subscript'?
36. How can you achieve multithreading in Swift?
37. Explain Swift's 'associatedtype' in protocols.
38. How does Swift handle optionals and unwrapping?
39. What are the benefits of using Swift's 'struct'?
40. What is the purpose of the 'associatedtype' keyword in Swift protocols?