1class X{
2 private int field = 1;
3 private void method(){}
4 void foo(X x){
5 x.field = 2;
6 x.method(); // this is OK, because we are accessing members from instance of X
7 // via reference of class X (which is same class as this one)
8 }
9
10 void bar(Y y){// = lets assume that Y extends X
11 y.field = 3;
12 y.method(); // ERROR: we can't access `method()`
13 }
14}
15