You cannot access the subclass field from the superclass. However you can change it in subclass like this:
public class B extends A {
B() {
this.a = "Jude";
}
}
This way you don't declare the new field, but change the value of existing one. Note that extends A is necessary to specify that B is subclass of A.
Alternatively you may consider using a method instead of field:
public class A {
public String getA() {
return "hey";
}
public void printA() {
System.out.println(getA());
}
}
public class B extends A {
@Override
public String getA() {
return "Jude";
}
}
Note that in Java "variable" term usually applied to local variables declared within methods. You are speaking about "field", not "variable".
extends Athe string would not be overwritten.