Suppose i have the following class structure. If i execute the child class, it will print both.
Inside Public method
Inside Private method
Could anyone explain the reason how the private method code is reachable to m1 ?
class Base
{
public void m1()
{
System.out.println("Inside Public method");
m2();
}
private void m2()
{
System.out.println("Inside Private method");
}
}
public class Child extends Base
{
public static void main(String[] args)
{
Child ob = new Child();
ob.m1();
}
}