How can inheritance break encapsulation?
class Base
{
private int i;
public Base(int i){
this.i = i;
}
public void getInt(){
return i;
}
public int setInt(int x){
// Do some valid checks here before returning a value.
this.i = x;
return i;
}
}
class Derived extends Base{
// If I override any of the above methods
// how can inheritance break the
// the encapsulated code of class Base
}