So I have the following code :
class Super {
private String name="super";
public String name(){
return this.name;
}
}
class Sub extends Super {
private String name = "sub";
}
public class Main {
public static void main(String[] args) {
System.out.println(new Sub().name());
}
}
what I get is as result is : super .
I wasnt to know why ?! Isn't the method name()
supposed to call this
of the object that was called from and since Sub
extends Super
then it should be able to use it on its members ?!