1.

Please consider the following code: (Advanced)

Answer»

The derived CLASS convenience initializers only and call convenience initializer or DESIGNATED initializer of own class. Ultimately the call chain should have designated initializer at last of the same class.

So the CORRECT code is :

class A {     var name:STRING     init(name:String) {         self.name = name     } } class B:A {     var id : String     init(name:String, id : String){         self.id = id         super.init(name: name)     }  convenience init (id:String) { self.init(name: "unknown", id: id)     } }


Discussion

No Comment Found

Related InterviewSolutions