Hi !
If i have understood correctly this ought to be with reference to a subclass - superclass situation. If that is so then the concept is that : it is the type of reference that will determine "WHAT" var/members can be accessed. But it is the underlying object "WHOSE" variables and methods will be accessed. Ok did i confuse u even more... here's an eg
class A
{
int x;
A()
{
x=10;
}
public void meth1()
{
// some code
}
}
class B extends A
{
int y;
B()
{
x=20;
y=30;
}
public void meth1()
{
//
}
public void meth2()
{
//
}
}
class C
{
public static void main(
String args[])
{
A a1=new B();
System.out.println(a1.x);
/*above will print 20 i.e the value defined in underlying object B()*/
System.out.println(a1.y);
/* above will give compiler error - saying undefined var - as y has not been declared in the superclass, and it is the reference (i.e. a1 here) which decides which members can be accessed. In short a1 will only be able to access all the var/ methods defined in A but the actual values of these var/ methods will be taken from B. Similarly u could go ahead with the methods (In case of overiding - the same principle applies)*/
}
}