As an example of a brain twist, my professor gave us the following exercises to learn about inheritance. We needed to find out the result.
The way out, as I expected
- af ()
- B β f ()
- A β f ()
- B β f ()
- A β f ()
- 19
However, now it has become interesting to me. Is there a way to make an f call to call method f in A, even if I use it from a B object, similar to how I call f from A to B using super.f (). Thus, the output will become (I think):
- af ()
- B β f ()
- A β f ()
- A β f ()
- 16
Is it possible? And if so, how?
Note. I'm not sure what the practical application of this will be, I'm just trying to learn something new: P
source share