Skip to content

Swift Programming Practice Exam

Test yourself under real exam conditions: 50 timed questions, 60 on the clock, pass mark 70%%. Instant score with a full review of everything you got wrong. Free — no account needed.

📝 50 questions · ⏱ 60 minutes · 🎯 Pass mark 70% · 🆓 Free, no signup

Exam details

  • 50 questions drawn from 50 cards
  • Countdown timer — auto-submits when time runs out
  • Pass mark 70% (real certification threshold)
  • Full review of wrong answers at the end
  • No signup required — save your score with a free account

Sample Questions

5 shown

What is an Optional in Swift?

Show ▼

An Optional in Swift represents a variable that can hold either a value or nil. It is declared using a ? after the type, e.g., var name: String?. Optionals enforce safe handling of the absence of a value at compile time.

How do you unwrap an Optional using if let?

Show ▼

You use optional binding with if let:
if let unwrapped = optionalValue {
  print(unwrapped)
}

This safely unwraps the optional and binds its value to a new constant within the block's scope.

What is the difference between Optional chaining and forced unwrapping?

Show ▼

Optional chaining uses ?. and returns nil if the optional is nil, failing gracefully.
Forced unwrapping uses ! and crashes at runtime if the optional is nil.
Example: person?.name vs person!.name

What is the nil-coalescing operator in Swift?

Show ▼

The nil-coalescing operator ?? provides a default value when an optional is nil.
Example: let name = optionalName ?? "Unknown"
If optionalName is nil, name is set to "Unknown".

What is an implicitly unwrapped optional?

Show ▼

An implicitly unwrapped optional is declared with ! instead of ?, e.g., var name: String!. It is automatically unwrapped when accessed, but will crash if it is nil. Used when a value is guaranteed to exist after initialization.

🎯 Take the Swift Programming Practice Exam