java - Overriding the public variables in super and sub class -
this question has answer here:
- overriding member variables in java 8 answers
hi create objects child class , try call child class variables called super class variable both super class , sub class have same class variable name
.
in output name "child" expecting "o2.name;" output "base".please explain me clearly...
variables not polymorphic in java; not override 1 another. when make variable of same name in subclass, that's called hiding. resulting subclass have both properties. can access 1 superclass super.var or ((superclass)this).var
Comments
Post a Comment