My question is about if there is a way to replace super to still call a parent method or a parent variable?
If there is way, is it similar to the use of super?
In quick words, is super replaceable?
Some languages do not implement the concept of subclassing (like Visual Basic, in earlier versions). A workaround to call "superclass methods" was to implement the delegate pattern, and instanciate the "superclass" (which was no real superclass) there. Then, the superclass was not invoked via the keyword super
, but via the delegation pattern. To understand the delegate pattern, see Design Pattern literature - or just https://en.wikipedia.org/wiki/Delegation_pattern
This concept describes how super
could be replaced by delegation - but there is no need to do so in Java. Simply don't do it.
And yes, there is a difference: When you instanciate a java object, you have this object instance, that provides all methods etc from its superclasses. When you implement the workaround with a delegate pattern, you have a second instance (the superclass-delegate would be a separate instance in this case).