+ 1
(JAVA)What happens with variables of the superclass when we use pholymorphism?
If I have a class and, then, I created another class like this: class [new class_name] extends [old class_name] {...etc..}. How I can use the variables of the superclass in the subclass? What are the limitations of pholymorphism? Does anyone have material about pholymorphism?
2 Answers
+ 10
1. You can access super attributes by super.variableName if the access modifier of the variable is public or protected.
2. [Edit] Private variables of the super class are not inherited.
3. https://docs.oracle.com/javase/tutorial/java/IandI/subclasses.html
+ 8
~ swim ~
I reread my statement and it is wrong in the current state. I'll correct it, thank you!