i know that constructors are not inherited in java and we have to implicitly or explicitly call them and private instance variables only accessible within the class's that they are declared. assume that we have a superclass with one private instance variable and we initialize it with superclass constructor for example
public class SuperClass
{
private int a;
public SuperClass ( int a )
{
this.a = a;
}
.
.
.
}
and our subclass is like this
public class SubClass extends SuperClass
{
public int b;
public SubClass ( int a, int b )
{
super( a );
this.b = b;
}
.
.
.
}
so here public SubClass ( int a, int b ) there is no problem even one of it's argument is private and belong to SuperClass??? if yes, how could it possible to access a private instance variable through another class???
this.a = a;actually touches the privatea. Parameters aren't the same as the instance.