fork download
  1. class Super
  2. {
  3. public static void main (String[] args) throws java.lang.Exception
  4. {
  5. new Sub();
  6. }
  7.  
  8. Super() {
  9. System.out.println("Super constructor");
  10. this.printThree();
  11. }
  12.  
  13. protected void printThree() {
  14. System.out.println("Super's printThree");
  15. }
  16. }
  17. class Sub extends Super
  18. {
  19. int three = this.initThree();
  20.  
  21. Sub() {
  22. this.printThree();
  23. }
  24.  
  25. private int initThree() {
  26. System.out.println("Sub's initThree");
  27. return 3;
  28. }
  29.  
  30. protected void printThree() {
  31. System.out.println("Sub's printThree: " + this.three);
  32. }
  33. }
Success #stdin #stdout 0.11s 320576KB
stdin
Standard input is empty
stdout
Super constructor
Sub's printThree: 0
Sub's initThree
Sub's printThree: 3