Consider the following code:
import java.io.*;
class a
{
public int var1;
}
class b extends a
{
public int var1;
}
class test
{
public static void main (String[] args)
{
b obj = new b();
System.out.println(obj.var1); // This should work!
System.out.println(obj.a.var1); // This doesn't seem to work!
// Is there any way to access the var1 inherited from a?
}
}
Is there any way through which we can access the member variables or the member functions of the parent class in the derived class?