class a{
public void show(){
System.out.println("parent");
}
}
public class override extends a{
protected void show(){
System.out.println("child");
}
public static void main(
String[] args) {
a a = new override();
a.show();
}
}
the program is not compiled.
it shows that subclass overridden method can not reduce the visibility of parent class method.
can anyone explain reason for this.
but the second program compiles fine
class a{
protected void show(){
System.out.println("parent");
}
}
public class override extends a{
public void show(){
System.out.println("child");
}
public static void main(String[] args) {
a a = new override();
a.show();
}
}