Swift (Coding) Quiz
Swift fundamentals: optionals, protocols, and modern Apple-platform development idioms.
This category currently has 60 questions in the SERVBG quiz bank. Below are a few sample questions: the full interactive quiz shuffles through the whole set with instant scoring.
Sample questions
In Swift, what is an Optional?
- A value that is always non-nil
- A keyword for default function arguments
- A protocol for hashable values
- A type that may hold a value or nil
- A reference type only
Which operator provides a default value when an Optional is nil?
- =>
- ?:
- ?? (nil-coalescing)
- !!
- <-
What does `if let x = optional { ... }` do?
- Forces unwrapping and crashes on nil
- Creates a weak reference to the optional
- Throws an error when nil
- Defines a computed property
- Unwraps the optional into x for the scope of the block when non-nil
What does `guard let x = optional else { return }` do?
- Marks x as @Published
- Crashes the program if x is nil
- Catches any thrown error
- Unwraps x for the rest of the scope or exits early when nil
- Defers x until end of scope
In Swift, struct vs class: which is a value type?
- class is a value type
- Both are reference types
- Both are value types
- Neither - they are interchangeable
- struct is a value type
Related categories
Python (Coding)
Python syntax and standard-library usage, from quick scripts to full applications.
JavaScript (Coding)
Core JavaScript behavior and async patterns, including the quirks that trip up beginners and veterans alike.
Linux
Linux command-line usage, file permissions, process management. The daily admin tasks.
Security
General information security concepts: common threats and standard defenses.
Hardware
Hardware components, how they interact, and basic troubleshooting to keep systems running.