1.

print("Apple”)   DispatchQueue.main.async {     print("iPod”)     DispatchQueue.main.async {         print("iPhone")     }     DispatchQueue.global().sync {         print("iPad")     }      print("Apple Watch")  }  print("Apple TV")

Answer»
  • Swift is static: The compiler must have all information about all classes and functions at compile time. You can "extend" an existing class (with an extension), but even then you must define completely at compile time what that extension CONSISTS of.
  • Objective-C is dynamic: Objective-C was extremely influenced by Smalltalk, which had demonstrated the BENEFITS of DUCK typing. This is also known as late binding, runtime binding, or the late dispatch. It’s dynamic because the responder of a MESSAGE isn’t baked in at compile time, but is deferred until the actual POINT of sending the message.


Discussion

No Comment Found

Related InterviewSolutions