fork download
  1. class Base {
  2. private static boolean goo = true;
  3.  
  4. protected static boolean foo() {
  5. goo = !goo;
  6. return goo;
  7. }
  8.  
  9. public String bar = "Base:" + foo();
  10.  
  11. public static void main(String[] args) {
  12. Base base = new Sub();
  13. System.out.println(base.bar);
  14. System.out.println(((Sub)base).bar);
  15. }
  16. }
  17.  
  18. class Sub extends Base {
  19. public String bar = "Sub:" + foo();
  20. }
Success #stdin #stdout 0.12s 320576KB
stdin
Standard input is empty
stdout
Base:false
Sub:true