output here is = 5 but not 15 why according to the code value of x is modified with 15
class A {
int x = 5;
public int getX() {
return this.x;
}
public void setX(int x) {
this.x = x;
}
}
class B extends A {
int x = 10;
public B() {
this.x = 15;
}
}
public class Test {
public static void main(String[] args) {
B a = new B();
System.out.println("hello" + a.getX());
}
}
is it because of the scope of variable