+ 2

How can we call first base class in multilevel inheritance

In oop, for eg class A is inherited to class B. When we make object of class B and call a function of common name then the function/ method in B will work this is called overriding. We can call base class function using SUPER keyword. My doubt is, consider if A is inherited to B and B is inherited to C and when we make object of class C how can we call method in A. If only 2 classes we can use ’super' keyword. What about 3 classes?

12th Jun 2022, 4:27 PM
Ajmal K saleem
Ajmal K saleem - avatar
2 ответов
+ 2
Super of C refers to the parent B. If you want to refers to the superclass A of B , use super() in B to make a chain. The constructor has this behavior by default. https://code.sololearn.com/cOwny2lnoTzI/?ref=app
12th Jun 2022, 10:10 PM
Roland
Roland - avatar
+ 1
I tried something.. If you add a method in C that returns super of B, you get super of A https://code.sololearn.com/ckVoEpxBnnxe/?ref=app
12th Jun 2022, 7:39 PM
Andrés Sebastián López
Andrés Sebastián López - avatar