Answer the question
In order to leave comments, you need to log in
When should super be called in an overridden method?
When overriding any method in a class heir, IDEA automatically prescribes a call to the parent method.
override fun method() {
super.method()
}
Answer the question
In order to leave comments, you need to log in
It is very dependent on the ancestor class, and the entire object model of the programming language. Suddenly, all classes are registered somewhere and calling super is just a given?
If it does work in the constructor that needs to be done so that you can work with it, then a call is needed.
For example, the ancestor class initializes some sockets or something else, and you decide to simply add your own property,
without super the class will not work as it should.
Moreover, you yourself decide when to do it, at least not to do it, at least at the beginning, at least at the end, at least by condition.
For example, in the callback methods of the Android system, these calls must be present. Why dont know.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question