well in K&B's book it was given that a protected member can only be accessed by a subclass in another package through inheritence and that the member behaves as being private to the subclass.
But on subclassing the subclass and compiling I found that the subclass of the subclass has also inherited the member. So the member isn't private to the first subclass.here's the code:
package a;
public class Parent{
protected int x;
protected void display(){}
}
package b;
import a.Parent;
class Child1 extends Parent{
int test1(){
x=4;
display();
return x;
}
}
package b;
import a.Parent;
class Child1s_child extends Child1{
public static void main(
String[] arg){
System.out.print(new Child1s_child().test1());
}
}
ur views
I wud like kathy to answer this one