FullStackFSCCafé
 
 
Sign in with GoogleSign in with Google. Opens in new tab
Kill Your Tech Interview
3877 Full-Stack, Algorithms & System Design Interview Questions
Answered To Get Your Next Six-Figure Job Offer
      
🤖 Having Machine Learning & DS Interview? Check  MLStack.Cafe - 1704 Data Science & ML Interview Questions & Answers!Having ML & DS Interview? Check 🤖 MLStack.Cafe - 1704 ML & DS Interview Questions and Answers

Top 72 Swift Interview Questions

Entry Junior Mid Senior Expert
Sign in with GoogleSign in with Google. Opens in new tab
Topic Progress:

Theoretical Questions

Q1:   

What are Extensions used for in Swift?

  
Add to PDF   Junior 
Q2:   

What is a Serial Queue?

  
Add to PDF   Junior 
Q3:   

What is the difference between Upcast and Downcast in Swift?

  
Add to PDF   Junior 
Q4:   

What’s the difference between == and ===?

  
Add to PDF   Junior 
Q5:   

When would you use self in a method?

  
 Add to PDF   Mid 
Q6:   

When to use @objc attribute?

  
 Add to PDF   Mid 
Q7:   

What is a good use case for an inout parameter?

  
 Add to PDF   Mid 
Q8:   

What is trailing closure syntax?

  
 Add to PDF   Mid 
Q9:   

What is the difference between a computed property and a property set to a closure?

  
 Add to PDF   Mid 
Q10:   

What is difference between as?, as! and as in Swift?

  
 Add to PDF   Mid 
Q11:   

What is typecasting?

  
 Add to PDF   Mid 
Q12:   

In Swift enumerations, what’s the difference between raw values and associated values?

  
 Add to PDF   Mid 
Q13:   

When to use a set rather than an array in Swift?

  
 Add to PDF   Mid 
Q14:   

What Classes and Structs have in common in Swift and what are their differences?

  
 Add to PDF   Mid 
Q15:   

What’s a strong reference, and why do we need it?

  
 Add to PDF   Mid 
Q16:   

What's the difference between Self vs self?

  
 Add to PDF   Mid 
Q17:   

What does the required keyword in Swift mean?

  
 Add to PDF   Mid 
Q18:   

When to use strong, weak and unowned references?

  
 Add to PDF   Mid 
Q19:   

What's the main difference between the Array, Set and Dictionary collection type?

  
 Add to PDF   Mid 
Q20:   

What does the Swift mutating keyword mean?

  
 Add to PDF   Mid 
Q21:   

What is the difference between let and var in Swift?

  
 Add to PDF   Mid 
Q22:   

Explain the defer usage in Swift

  
 Add to PDF   Mid 
Q23:   

What are the differences between functions and methods in Swift?

  
 Add to PDF   Mid 
Q24:   

How to sort array of custom objects by property value in Swift?

  
 Add to PDF   Mid 
Q25:   

Explain the difference between DispatchQueue.main.async and DispatchQueue.main.sync?

  
 Add to PDF   Mid 
Q26:   

When should I use deinit?

  
 Add to PDF   Mid 
Q27:   

What’s the difference between a protocol and a class in Swift?

  
 Add to PDF   Mid 
Q28:   

What is the autoclosure attribute and when to use it?

  
 Add to PDF   Senior 
Q29:   

What is the difference between ARC (automatic reference counting) and GC (garbage collection)?

  Related To: Objective-C, iOS
 Add to PDF   Senior 
Q30:   

What’s the difference between a static variable and a class variable?

  
 Add to PDF   Senior 
Q31:   

What is QoS (Quality of Service) in GCD?

  Related To: iOS
 Add to PDF   Senior 
Q32:   

What is the difference between open and public keywords in Swift?

  
 Add to PDF   Senior 
Q33:   

What is the difference between functions and closures?

  
 Add to PDF   Senior 
Q34:   

Can you rewrite this code using mutating function?

  
 Add to PDF   Senior 
Q35:   

What is the difference between static func and class func in Swift?

  
 Add to PDF   Senior 
Q36:   

Are there any differences between Protocol in Swift vs Interface in Java?

  Related To: Java
 Add to PDF   Senior 
Q37:   

Is there a way to create an abstract class in Swift?

  
 Add to PDF   Senior 
Q38:   

What is the difference between fileprivate and private?

  
 Add to PDF   Senior 
Q39:   

What’s the difference between Any and AnyObject?

  
 Add to PDF   Senior 
Q40:   

When to use fileprivate access modifier in Swift?

  
 Add to PDF   Senior 
Q41:   

Explain when to use different Swift casting operators?

  
 Add to PDF   Senior 
Q42:   

What's wrong with this code?

  
 Add to PDF   Senior 
Q43:   

When should you use Structs over Classes?

  
 Add to PDF   Senior 
Q44:   

When should you use Classes over Structs?

  
 Add to PDF   Senior 
Q45:   

What is Copy on Write (Cow) in Swift?

  
 Add to PDF   Senior 
Q46:   

Explain the difference between weak and unowned references. Provide an example.

  
 Add to PDF   Senior 
Q47:   

When is it safe to use an unowned reference?

  
 Add to PDF   Senior 
Q48:   

What's the difference between marking a method as @objc vs dynamic, when would you do one vs the other?

  Related To: Objective-C
 Add to PDF   Expert 
Q49:   

Explain usage of Concurrent vs Serial Queues with async and sync blocks

  Related To: iOS
 Add to PDF   Expert 
Q50:   

Explain how that code will behave for different Swift versions?

  
 Add to PDF   Expert 
Q51:   

What is the difference between @escaping and @nonescaping Closures in Swift?

  
 Add to PDF   Expert 
Q52:   

What are the benefits of using DispatchWorkItem in Swift?

  Related To: iOS
 Add to PDF   Expert 
Q53:   

Explain what is DispatchGroup?

  
 Add to PDF   Expert 
Q54:   

Explain the use case when ARC won't help you to release memory (but GC will)?

  Related To: Objective-C, iOS
 Add to PDF   Expert 
Q55:   

Why can not we just use weak everywhere and forget about unowned?

  
 Add to PDF   Expert 
Q56:   

Do we need to use [weak self] or [unowned self] in this closure?

  
 Add to PDF   Expert 
Q57:   

What is the Never return type? When to use it over Void?

  
 Add to PDF   Expert 
Q58:   

What’s the difference between init?() and init()?

  
 Add to PDF   Expert 
Q59:   

What is the use of Hashable protocol?

  
 Add to PDF   Expert 

Code Challenges

Q1:   

Determine the value of x in the Swift code below. Explain your answer.

  
 Add to PDF   Junior 
Q2:   

How to iterate a loop with index and element in Swift?

  
 Add to PDF   Junior 
Q3:   

How can I check if an object is of a given type in Swift?

  
  Add to PDF   Mid 
Q4:   

Rewrite this code in a Swift way

  
  Add to PDF   Mid 
Q5:   

Why and how to use associated values in enums?

  
  Add to PDF   Mid 
Q6:   

How to append one array to another array in Swift?

  
  Add to PDF   Mid 
Q7:   

How to break out of multiple loop levels?

  
  Add to PDF   Mid 
Q8:   

Provide an example of code with a memory leak

  
  Add to PDF   Senior 
Q9:   

Explain what will be the output of this code?

  
  Add to PDF   Senior 
Q10:   

What to use: [String: Any] or [String: AnyObject]?

  
  Add to PDF   Senior 
Q11:   

How to add a custom initializer to a struct without losing its memberwise initializer?

  
  Add to PDF   Senior 
Q12:   

How to optimize this code?

  
  Add to PDF   Senior 
Q13:   

How to deal with retain cycles in Closures? Provide an example.

  
  Add to PDF   Expert 
 

Rust has been Stack Overflow’s most loved language for four years in a row and emerged as a compelling language choice for both backend and system developers, offering a unique combination of memory safety, performance, concurrency without Data races...

Clean Architecture provides a clear and modular structure for building software systems, separating business rules from implementation details. It promotes maintainability by allowing for easier updates and changes to specific components without affe...

Azure Service Bus is a crucial component for Azure cloud developers as it provides reliable and scalable messaging capabilities. It enables decoupled communication between different components of a distributed system, promoting flexibility and resili...

Cosmos DB has gained popularity among developers and organizations across various industries, including finance, e-commerce, gaming, IoT, and more. Follow along and learn the 24 most common and advanced Azure Cosmos DB interview questions and answers...
More than any other NoSQL database, and dramatically more than any relational database, MongoDB's document-oriented data model makes it exceptionally easy to add or change fields, among other things. It unlocks Iteration on the project. Iteration f...
Unit Tests and Test Driven Development (TDD) help you really understand the design of the code you are working on. Instead of writing code to do something, you are starting by outlining all the conditions you are subjecting the code to and what outpu...
Domain-Driven Design is nothing magical but it is crucial to understand the importance of Ubiquitous Language, Domain Modeling, Context Mapping, extracting the Bounded Contexts correctly, designing efficient Aggregates and etc. before your next DDD p...
At its core, Microsoft Azure is a public cloud computing platform - with solutions including Infrastructure as a Service (IaaS), Platform as a Service (PaaS), and Software as a Service (SaaS) that can be used for services such as analytics, virtual c...
As an asynchronous event-driven JavaScript runtime, Node.js is designed to build scalable network applications. Follow along to refresh your knowledge and explore the 52 most frequently asked and advanced Node JS Interview Questions and Answers every...
Dependency Injection is most useful when you're aiming for code reuse, versatility and robustness to changes in your problem domain. DI is also useful for decoupling your system. DI also allows easier unit testing without having to hit a database and...