Learn Swift Fundamentals by preparing for Job Interview, Questions 39 ~ 44 For Initializer

Swift has a lot of different initializers. I was very confused at first too. If you know exactly this concept, your interviewers will be impressed!

39) What is initializer?

Answer:

  • Initializer is a method that constructs the object with proper default values.
swift initializer

40) What are the different types of initializers available in Swift?

Answer:

  • Default
  • Customized
  • Convenience
  • Failable
  • Required
Swift has many initializers

41) What is the default initializer in Swift?

Answer:

  • init is the default initializer in Swift.
Swift Default Initializers

42) What is parameterized / Custom Initializer?

Answer:

  • init method with some input parameters to construct the object with custom values.
Swift Custom Initilizer

43) What is designated initializer in Swift?

Answer:

Default init method is the designated initializer

44) What is convenience initializer in Swift?

Answer:

  • Convenience Initializer is a kind of initializer which sets custom values for a few properties of an Object. Use convenience keyword to create convenience initializer.
  • Designated initializer must be called before setting the custom values.
Convenience Initializer

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
KD Knowledge Diet

Software Engineer, Mobile Developer living in Seoul. I hate people using difficult words. Why not using simple words? Keep It Simple Stupid!