Complete the code to define a designated initializer for the class.
class Person { var name: String init([1]: String) { self.name = name } }
The parameter name in the initializer must match the property name to assign it correctly.
Complete the code to call the designated initializer from a convenience initializer.
class Vehicle { var wheels: Int init(wheels: Int) { self.wheels = wheels } convenience init() { self.[1](wheels: 4) } }
Convenience initializers call the designated initializer using 'self.init'.
Fix the error in the initializer by completing the missing keyword.
class Animal { var species: String [1] init(species: String) { self.species = species } }
The 'required' keyword ensures subclasses implement this initializer.
Fill both blanks to create a designated initializer with a default parameter value.
class Book { var title: String var pages: Int init(title: String, pages: [1] = [2]) { self.title = title self.pages = pages } }
The parameter 'pages' is of type Int with a default value 100.
Fill all three blanks to complete the subclass initializer calling the superclass designated initializer.
class Employee: Person { var id: Int init(name: String, id: [1]) { self.id = id super.[2](name: [3]) } }
The subclass initializer takes an Int id, calls 'super.init' with the name parameter.