class A {
public void talk(){
this.sayIt();
}
private void sayIt(){
System.out.println("class A says...");
}
}
class B extends A {
private void sayIt(){
System.out.println("class B says...");
}
}
B b = new B();
b.talk()
//output
class A says...
I cannot get this since:
Class B inherits from class A the public member and cannot see/inherit the private function.
So in class B we could call talk() //since it is inherited by the parent class.
Now in the talk() method there is a call to sayIt() and since say it is defined in class B i would expect a call to B.sayIt() to be made when this.sayIt() is executed.
Doesn't "this" refer to the B class ?
If you have some time please explain..