In general, the super keyword can be used to call overridden methods, access hidden fields or invoke a superclass's constructor. The one with super has greater flexibility The call chain for the methods can be intercepted and functionality injected. Super() lets you avoid referring to the base class explicitly, which can be nice But the main advantage comes with multiple inheritance, where all sorts of fun stuff can happen. In fact, multiple inheritance is the only case where super() is of any use
I would not recommend using it with classes using linear inheritance, where it's just useless overhead. I'm currently learning about class inheritance in my java course and i don't understand when to use the super() call I found this example of code where super.variable is used As for chaining super::super, as i mentionned in the question, i have still to find an interesting use to that For now, i only see it as a hack, but it was worth mentioning, if only for the differences with java (where you can't chain super). Super e>) says that it's some type which is an ancestor (superclass) of e
(in both cases e itself is okay.) so the constructor uses the Extends e form so it guarantees that when it fetches values from the collection, they will all be e or some subclass (i.e I wrote the following code When i try to run it as at the end of the file i get this stacktrace 'super' object has no attribute do_something class parent The automatic insertion of super () by the compiler allows this
Enforcing super to appear first, enforces that constructor bodies are executed in the correct order which would be What is the difference between the keywords this and super Both are used to access constructors of class right Can any of you explain?
OPEN