This is because the subclass has private visibility for the void func() method, but the superclass has public visibility.
If your code was allowed to compile, it will explode at runtime if you did:
parent p = new TestClass(); p.func(); // boom - func is public in parent, but TestClass impl is private, so no access would be allowed
To โfixโ this, subclass the func public method:
public class TestClass extends parent { ... public void func() {
And please use standard naming conventions; in this case, "classes must start with a capital letter" - ie Parent not Parent
source share