All questions
of 51What's the difference between `var` and `let` in Swift?
Answer it yourself first - out loud, or typed below.
How should your speech become text?
Listening… your words appear above as you speak - tap Stop when you're done.
Recording · cr - tap Stop & transcribe when you're done.
Transcribing with AI…
Voice:
Last attempt -
vardeclares a mutable variable that can be changed after initializationletdeclares an immutable constant that cannot be changed after initialization
var name = "John" // Mutable
name = "Jane" // ✅ Valid
let age = 25 // Immutable
age = 26 // ❌ Compile error
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
The model's verdict: “”
The interactive diagram is below the answer - jump to diagram ↓
This answer is explained by a shared concept diagram - open →
Explain the difference between Swift and Objective-C.
Answer it yourself first - out loud, or typed below.
How should your speech become text?
Listening… your words appear above as you speak - tap Stop when you're done.
Recording · cr - tap Stop & transcribe when you're done.
Transcribing with AI…
Voice:
Last attempt -
| Swift | Objective-C |
|---|---|
| Type-safe and memory-safe | Manual memory management |
| Modern, clean syntax | C-based syntax with square brackets |
| Compiled language | Dynamic runtime |
| Built-in optionals | Manual nil checking |
| Value types (structs) emphasis | Reference types (classes) emphasis |
| Faster performance | Slower due to dynamic dispatch |
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
The model's verdict: “”
The interactive diagram is below the answer - jump to diagram ↓
This answer is explained by a shared concept diagram - open →
What are the basic data types in Swift?
Answer it yourself first - out loud, or typed below.
How should your speech become text?
Listening… your words appear above as you speak - tap Stop when you're done.
Recording · cr - tap Stop & transcribe when you're done.
Transcribing with AI…
Voice:
Last attempt -
Swift provides several basic data types:
- Int: Integer numbers (Int8, Int16, Int32, Int64)
- Double: 64-bit floating-point numbers
- Float: 32-bit floating-point numbers
- Bool: Boolean values (true/false)
- String: Text data
- Character: Single character
let integer: Int = 42
let double: Double = 3.14159
let boolean: Bool = true
let text: String = "Hello"
let character: Character = "A"
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
The model's verdict: “”
The interactive diagram is below the answer - jump to diagram ↓
This answer is explained by a shared concept diagram - open →
Explain type inference and type annotations in Swift.
Answer it yourself first - out loud, or typed below.
How should your speech become text?
Listening… your words appear above as you speak - tap Stop when you're done.
Recording · cr - tap Stop & transcribe when you're done.
Transcribing with AI…
Voice:
Last attempt -
Type Inference: Swift can automatically determine variable types based on assigned values.
Type Annotations: Explicitly declaring variable types.
// Type inference
let name = "John" // Inferred as String
let age = 25 // Inferred as Int
// Type annotations
let name: String = "John"
let age: Int = 25
let numbers: [Int] = [1, 2, 3]
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
The model's verdict: “”
The interactive diagram is below the answer - jump to diagram ↓
This answer is explained by a shared concept diagram - open →
What are optionals in Swift and why are they important?
Answer it yourself first - out loud, or typed below.
How should your speech become text?
Listening… your words appear above as you speak - tap Stop when you're done.
Recording · cr - tap Stop & transcribe when you're done.
Transcribing with AI…
Voice:
Last attempt -
Optionals represent a value that might be present or absent (nil). They provide null safety and prevent runtime crashes from accessing nil values.
var name: String? = "John"
name = nil // Valid
var age: Int = 25
age = nil // ❌ Compile error - Int cannot be nil
Optionals are important because they:
- Eliminate null pointer exceptions
- Make nil handling explicit
- Improve code safety and reliability
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
The model's verdict: “”
The interactive diagram is below the answer - jump to diagram ↓
This answer is explained by a shared concept diagram - open →
How do you define functions in Swift?
Answer it yourself first - out loud, or typed below.
How should your speech become text?
Listening… your words appear above as you speak - tap Stop when you're done.
Recording · cr - tap Stop & transcribe when you're done.
Transcribing with AI…
Voice:
Last attempt -
// Basic function
func greet(name: String) -> String {
return "Hello, \(name)!"
}
// Function with multiple parameters
func add(a: Int, b: Int) -> Int {
return a + b
}
// Function with no return value
func printMessage() {
print("Hello World")
}
// Function with default parameters
func greet(name: String = "World") -> String {
return "Hello, \(name)!"
}
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
The model's verdict: “”
The interactive diagram is below the answer - jump to diagram ↓
This answer is explained by a shared concept diagram - open →
What is inheritance in Swift?
Answer it yourself first - out loud, or typed below.
How should your speech become text?
Listening… your words appear above as you speak - tap Stop when you're done.
Recording · cr - tap Stop & transcribe when you're done.
Transcribing with AI…
Voice:
Last attempt -
Inheritance allows classes to inherit properties and methods from another class.
// Base class
class Vehicle {
var wheels: Int
init(wheels: Int) {
self.wheels = wheels
}
func start() {
print("Vehicle starting")
}
}
// Derived class
class Car: Vehicle {
var doors: Int
init(doors: Int) {
self.doors = doors
super.init(wheels: 4) // Call parent initializer
}
override func start() {
super.start() // Call parent method
print("Car engine starting")
}
}
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
The model's verdict: “”
The interactive diagram is below the answer - jump to diagram ↓
This answer is explained by a shared concept diagram - open →
What are protocols in Swift?
What are extensions in Swift?
What's the difference between `String` and `NSString`?
What are the different ways to unwrap optionals?
What's the difference between implicitly unwrapped optionals and regular optionals?
What are closures in Swift?
Explain the difference between escaping and non-escaping closures.
What are higher-order functions in Swift?
What's the difference between classes and structures in Swift?
When should you use a class vs. a struct?
What are designated and convenience initializers?
What's the difference between protocols and inheritance?
What are protocol extensions and their benefits?
What is ARC (Automatic Reference Counting)?
What are retain cycles and how do you prevent them?
What's the difference between `weak` and `unowned` references?
How does error handling work in Swift?
What are the different ways to handle errors in Swift?
What is the `Result` type in Swift?
What are generics in Swift?
What are type constraints in generics?
What are enums and associated values?
What is pattern matching in Swift?
What is async/await in Swift?
What is lazy evaluation in Swift?
How do you handle memory leaks in closures?
What are the best practices for writing Swift code?
What are associated types in protocols?
What are property wrappers in Swift?
What are keypaths in Swift?
What is copy-on-write in Swift?
What are actors in Swift?
What is the difference between `async` and `@escaping` closures?
What are Tasks in Swift concurrency?
What are the performance differences between classes and structs?
What is method dispatch in Swift?
How can you optimize Swift code performance?
What is protocol-oriented programming?
What are phantom types in Swift?
What is function composition in Swift?
What are existential types and type erasure?
What is the difference between `some` and `any` in Swift?
What are sendable types in Swift concurrency?
What is the `@MainActor` attribute?
This answer is part of Pro.
The full written answer, with the trade-offs and follow-ups an interviewer will probe.
No matches
Try a different filter or search term.
Swift cheatsheet
Swift Interview Cheat Sheet
- Overview01
- Why Swift Matters02
- Basics03
- Optionals04
- Control Flow05
- Functions & Closures06
- Classes & Structs07
- Protocols & Extensions08
- Memory Management09
- Error Handling10
- Generics11
- Concurrency12
- + 3 more inside
44 of 51 Swift answers are gated.
Full answers, code samples, AI explanations - simpler, deeper, or as an interactive diagram. Cancel anytime.
- Full answers + code
- AI explain - simpler, deeper, or visualized
- 1,000 AI credits / month
- Cancel anytime
Change topic
Pick a different technology or stack. Your current topic stays put until you choose a new one.
MEAN
MongoDB, Express, Angular, Node.jsMERN
MongoDB, Express, React, Node.jsLAMP
Linux, Apache, MySQL, PHPRuby on Rails
Convention over ConfigurationJAM
JavaScript, APIs, and MarkupServerless on AWS
Serverless Architecture on AWSInterviewers also test these - they're common to every stack, whichever one you picked above.
Flutter Mobile
Flutter Cross-Platform Mobile DevelopmentInterviewers also test these - they're common to every stack, whichever one you picked above.
Spring Boot
Enterprise Java Development.NET
Microsoft EcosystemVue
Vue.js, Vite, TypeScript, Tailwind, Node.jsGo Backend
Golang, gRPC, PostgreSQL, Redis, RabbitMQFastAPI
Python, FastAPI, SQLAlchemy, PostgreSQLReact Native
React, TypeScript, Redux, FirebaseiOS Native
Swift, SwiftUI, UIKit, FirebaseAndroid Native
Java, Jetpack Compose, FirebaseWeb3 / Ethereum
Solidity, Ethereum, Hardhat, FoundryDevOps / Platform
Docker, Kubernetes, Terraform, CI/CDCore SWE Interview Prep
Data structures, algorithms, OS, concurrency, networking, gitInterviewers also test these - they're common to every stack, whichever one you picked above.
Interviewers also test these - they're common to every stack, whichever one you picked above.