LearnThatStack Ace your next interview
Mobile Development
Swift.
51 Qs 7 free
Change topic Change
Drill · questions

All questions

of 51
Beginner 9
01

What's the difference between `var` and `let` in Swift?

Beginner ·

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:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain
  • var declares a mutable variable that can be changed after initialization
  • let declares an immutable constant that cannot be changed after initialization
var name = "John"  // Mutable
name = "Jane"      // ✅ Valid

let age = 25       // Immutable
age = 26          // ❌ Compile error
Rewriting in plainer words…

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

Tailored explanation · switch back to · ·
Point the redraw:
How well did you know this?
AI:

02

Explain the difference between Swift and Objective-C.

Beginner ·

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:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain
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
Rewriting in plainer words…

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

Tailored explanation · switch back to · ·
Point the redraw:
How well did you know this?
AI:

03

What are the basic data types in Swift?

Beginner ·

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:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

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"
Rewriting in plainer words…

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

Tailored explanation · switch back to · ·
Point the redraw:
How well did you know this?
AI:

04

Explain type inference and type annotations in Swift.

Beginner ·

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:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

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]
Rewriting in plainer words…

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

Tailored explanation · switch back to · ·
Point the redraw:
How well did you know this?
AI:

05

What are optionals in Swift and why are they important?

Beginner ·

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:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

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
Rewriting in plainer words…

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

Tailored explanation · switch back to · ·
Point the redraw:
How well did you know this?
AI:

06

How do you define functions in Swift?

Beginner ·

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:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain
// 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)!"
}
Rewriting in plainer words…

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

Tailored explanation · switch back to · ·
Point the redraw:
How well did you know this?
AI:

07

What is inheritance in Swift?

Beginner ·

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:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

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")
    }
}
Rewriting in plainer words…

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

Tailored explanation · switch back to · ·
Point the redraw:
How well did you know this?
AI:

08

What are protocols in Swift?

Part of Pro
09

What are extensions in Swift?

Part of Pro
Intermediate 25
10

What's the difference between `String` and `NSString`?

Part of Pro
11

What are the different ways to unwrap optionals?

Part of Pro
12

What's the difference between implicitly unwrapped optionals and regular optionals?

Part of Pro
13

What are closures in Swift?

Part of Pro
14

Explain the difference between escaping and non-escaping closures.

Part of Pro
15

What are higher-order functions in Swift?

Part of Pro
16

What's the difference between classes and structures in Swift?

Part of Pro
17

When should you use a class vs. a struct?

Part of Pro
18

What are designated and convenience initializers?

Part of Pro
19

What's the difference between protocols and inheritance?

Part of Pro
20

What are protocol extensions and their benefits?

Part of Pro
21

What is ARC (Automatic Reference Counting)?

Part of Pro
22

What are retain cycles and how do you prevent them?

Part of Pro
23

What's the difference between `weak` and `unowned` references?

Part of Pro
24

How does error handling work in Swift?

Part of Pro
25

What are the different ways to handle errors in Swift?

Part of Pro
26

What is the `Result` type in Swift?

Part of Pro
27

What are generics in Swift?

Part of Pro
28

What are type constraints in generics?

Part of Pro
29

What are enums and associated values?

Part of Pro
30

What is pattern matching in Swift?

Part of Pro
31

What is async/await in Swift?

Part of Pro
32

What is lazy evaluation in Swift?

Part of Pro
33

How do you handle memory leaks in closures?

Part of Pro
34

What are the best practices for writing Swift code?

Part of Pro
Expert 17
35

What are associated types in protocols?

Part of Pro
36

What are property wrappers in Swift?

Part of Pro
37

What are keypaths in Swift?

Part of Pro
38

What is copy-on-write in Swift?

Part of Pro
39

What are actors in Swift?

Part of Pro
40

What is the difference between `async` and `@escaping` closures?

Part of Pro
41

What are Tasks in Swift concurrency?

Part of Pro
42

What are the performance differences between classes and structs?

Part of Pro
43

What is method dispatch in Swift?

Part of Pro
44

How can you optimize Swift code performance?

Part of Pro
45

What is protocol-oriented programming?

Part of Pro
46

What are phantom types in Swift?

Part of Pro
47

What is function composition in Swift?

Part of Pro
48

What are existential types and type erasure?

Part of Pro
49

What is the difference between `some` and `any` in Swift?

Part of Pro
50

What are sendable types in Swift concurrency?

Part of Pro
51

What is the `@MainActor` attribute?

Part of Pro

No matches

Try a different filter or search term.

Pro · $10/mo

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.

Technologies
No technologies match “”.
Cross-cutting topics
No topics match “”.
By role
Stacks & frameworks

MEAN

MongoDB, Express, Angular, Node.js

MERN

MongoDB, Express, React, Node.js

LAMP

Linux, Apache, MySQL, PHP

Django

Python Full-Stack Development

Ruby on Rails

Convention over Configuration

JAM

JavaScript, APIs, and Markup

Serverless on AWS

Serverless Architecture on AWS

Cross-cutting topics 43 topics

Interviewers also test these - they're common to every stack, whichever one you picked above.

Flutter Mobile

Flutter Cross-Platform Mobile Development

Cross-cutting topics 44 topics

Interviewers also test these - they're common to every stack, whichever one you picked above.

Spring Boot

Enterprise Java Development

.NET

Microsoft Ecosystem

Vue

Vue.js, Vite, TypeScript, Tailwind, Node.js

Go Backend

Golang, gRPC, PostgreSQL, Redis, RabbitMQ

FastAPI

Python, FastAPI, SQLAlchemy, PostgreSQL

React Native

React, TypeScript, Redux, Firebase

iOS Native

Swift, SwiftUI, UIKit, Firebase

Android Native

Java, Jetpack Compose, Firebase

Web3 / Ethereum

Solidity, Ethereum, Hardhat, Foundry

DevOps / Platform

Docker, Kubernetes, Terraform, CI/CD

Core SWE Interview Prep

Data structures, algorithms, OS, concurrency, networking, git
Big-O & Complexity Analysis Arrays, Strings & Hash Tables Linked Lists, Stacks & Queues Trees, BSTs & Heaps Graphs Sorting, Searching & Recursion Operating Systems Concurrency & Multithreading Networking for Developers Git & Version Control API Design 45 Distributed Systems Fundamentals 34

Cross-cutting topics 43 topics

Interviewers also test these - they're common to every stack, whichever one you picked above.


Cross-cutting topics 45 topics

Interviewers also test these - they're common to every stack, whichever one you picked above.