Swift (Coding) Quiz
Swift language fundamentals — optionals, protocols, and the idioms behind modern Apple-platform development.
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 type that may hold a value or nil
- A value that is always non-nil
- A protocol for hashable values
- A keyword for default function arguments
- A reference type only
Which operator provides a default value when an Optional is nil?
- !!
- =>
- ?:
- <-
- ?? (nil-coalescing)
What does `if let x = optional { ... }` do?
- Unwraps the optional into x for the scope of the block when non-nil
- Defines a computed property
- Throws an error when nil
- Creates a weak reference to the optional
- Forces unwrapping and crashes on nil
What does `guard let x = optional else { return }` do?
- Catches any thrown error
- Crashes the program if x is nil
- Unwraps x for the rest of the scope or exits early when nil
- Marks x as @Published
- Defers x until end of scope
In Swift, struct vs class: which is a value type?
- Both are reference types
- Neither - they are interchangeable
- Both are value types
- class is a value type
- struct is a value type
Related categories
Python (Coding)
Python syntax, standard-library usage, and the language idioms that come up in day-to-day scripting and application work.
JavaScript (Coding)
Core JavaScript language behavior, async patterns, and the quirks that trip up both beginners and experienced developers.
Linux
Linux command-line usage, file permissions, process management, and the everyday admin tasks every sysadmin and developer needs.
Security
General information security concepts — threats, defenses, and the fundamentals every IT professional should know.
Hardware
Computer hardware components, how they interact, and the troubleshooting knowledge behind keeping systems running.