fork download
  1. class Ideone {
  2. public static void main (String[] args) {
  3. ChildClass c = new ChildClass();
  4. c.methodB();
  5. }
  6. }
  7.  
  8. class ParentClass {
  9. private void methodA() {
  10. System.out.println("This is Parent A Method");
  11. }
  12.  
  13. public void methodB() {
  14. System.out.println("This is Parent B Method and I am Calling Method A");
  15. methodA();
  16. }
  17. }
  18.  
  19. class ChildClass extends ParentClass {
  20. public void methodA() {
  21. System.out.println("This is Child A Method and I am Calling Parents Method A");
  22. super.methodA();
  23. }
  24.  
  25. @Override
  26. public void methodB() {
  27. System.out.println("This is Child B Method and I am Calling Parents Method B");
  28. super.methodB();
  29. }
  30. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:22: error: methodA() has private access in ParentClass
        super.methodA();
             ^
1 error
stdout
Standard output is empty