We can access Private data members using accessor method such as
private int num=5;
public int get_num()
{
return num;
}
and we can access the returned value from any class even though num is private data member.
So on Similar note cant we create accessor method that returns private methods? I just had a thought about it,If we cannot do this please explain.Thank You
You can access private method via public method. This is sometimes used to wrap complicated private method and expose simpler, public API.
You can also access private methods using reflection. http://tutorials.jenkov.com/java-reflection/private-fields-and-methods.html