+ 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?

25th Apr 2019, 8:50 PM
Rosana Rodríguez Milanés
Rosana Rodríguez Milanés - avatar
2 Réponses
+ 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
25th Apr 2019, 9:00 PM
Tashi N
Tashi N - avatar
+ 8
~ swim ~ I reread my statement and it is wrong in the current state. I'll correct it, thank you!
26th Apr 2019, 7:00 AM
Tashi N
Tashi N - avatar