Hello,
i am preparing for
java SE certification exam and playing a little bit with the code. From the theory :
- private methods are not inherited (and therefore cannot be overriden)
- non static class methods cannot be executed without instance of the class
in this sample code I have Parent and Child classes, Parent has a private method
test(), Child extends Parent, but since the only non static method in Parent class is private, Child doesn't inherit it. In the Parent's main method I execute test() method on reference (type Parent), which reffers to Child instance. How is it possible that Parent's test() method is executed without instance of Parent?