fork download
  1. class A {
  2. int v;
  3. }
  4.  
  5. class B extends A {
  6. int v;
  7. }
  8.  
  9. class Main
  10. {
  11. public static void main (String[] args) throws Exception {
  12. B b = new B();
  13. b.v = 5;
  14. ((A)b).v = 9;
  15. System.out.println(b.v + " " + ((A)b).v);
  16. A a = b;
  17. System.out.println(a.v);
  18. }
  19. }
Success #stdin #stdout 0.02s 245632KB
stdin
Standard input is empty
stdout
5 9
9