package testpkg.p1;
public class ParentUtil
{
public int x = 420;
protected int dostuff()
{
return x;
}
}
package testpkg.p2;
import testing.p1.ParentUtil;
public class ChildUtil extends ParentUtil
{
public static void main(
String[] agrs)
{
new ChildUtil.callStuff();
}
void callStuff()
{
System.out.println("this"+this.dostuff());
ParentUtil p = new ParenUtil();
System.out.println("parent"+p.dostuff());//Ans: Error In this line
}
}
Can any one tell why it will show error? Can�t we access the protected member or method from which class extends the other class which is in different package?