Friday, June 27, 2014

what happens when visibility of public method is reduced in subclass (public to private)?

public class Test1 {
  public static void main(String[] args) {
  }
   public void add(){
   }
}

class Test2 extends Test1 {
    private void add(){
    }
}

Compile time error :

Cannot reduce the visibility of the inherited method from Test1

No comments:

Post a Comment