Sunday, April 9, 2017

Overloading - Access Level

In the scenario of method overloading. The access modifier of methods can be less restrictive or more accessible. There are two methods eat() and sleep(). One is public and other is protected in class P. You see there are restrictive and more accessible version of methods.

class P
{
  public void eat() {}
  protected void eat(int a) {}
 
  protected void sleep() {}
  private void sleep(String s) {}
  public void sleep(String s, float x) {}
 
}

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

No comments:

Post a Comment

Abstraction vs Interface

Abstract Interface method abstract and concrete abstract only, support default and static method ...