Inherited methods access level..
Hello,
I have two classes.X and Y . Y extends X.
class X{
public X(){
System.out.print("default");
}
public X(int x){
}
int f1(int a){
System.out.print("f1 "+a);
return 1;
}
}
class Yextends X{
public Y(int y){
}
protectedint f1(int a){
System.out.print("f1"+a);
return 1;
}
}
The f1 method in X class has default scope but f1 method in Y class has protected scope. default scope is wider than protected class.
so why didn't the compiler argued about this?
[1533 byte] By [
xyzta] at [2007-11-26 18:21:50]

> default scope is wider than protected class
It's actually the other way around: protected scope is wider than default scope.
Protected scope makes a method visible in subclasses and throughout the current package; Default scope makes a method visible throughout the current package.
> The f1 method in X class has default scope but f1 method in Y class
> has protected scope. default scope is wider than protected class.
Nope, it's the other way around. Default scoped things are not visible
anywhere outside the package while protected thingies are visible
*in* the package as well as in anything extending that particular class.
kind regards,
Jos