private method access confusion
when i execute subtest class using java2 , the following code is
running successfully and giving the output message " main executed" .
how can a private method of superclass is being accessed in sub class?
-------------------------------
public class subtest extends test {
}
class test {
private static void main(String args[]) {
System.out.println("main executed" );
}
}
Re: private method access confusion
They cannot be accessed! The whole point of a class member (variable or method)
being private is that they cannot be accessed by other classes - even sub
classes.