thanks for the reply
see this sample code and tell me what is happening at line 1
public class
Testing {
private int a;
public Testing(){
this.a=5; // line 1
System.out.println("super"+this.a);
this.changeA(9);
}
public void changeA(int a){
this.a=a;
}
static public void main(
String[] args){
Test1 obj=new Test1();
}
}
class Test1 extends Testing{
private int b;
public Test1(){
System.out.println("this"+this.b);
}
public void changeA(int a){
this.b=7;
}
}
what i think is...
when we say this.a=5....since the current instance in execution is Test1 object.The Test1 class doesnot have varibale named "a" then the jvm will search for the variable in super class finds it and the value 5 will be assigned...but the variable "a" is declared private..
So, form this what i conclude is subclass reference can access the private variables of the superclass within the context of Superclass..