fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.io.*;
  4.  
  5. class Base
  6. {
  7. public int m = 1;
  8. }
  9.  
  10. class Derived extends Base
  11. {
  12. public int m = 2;
  13. }
  14.  
  15. /* Name of the class has to be "Main" only if the class is public. */
  16. class Ideone
  17. {
  18. public static void main (String[] args) throws java.lang.Exception
  19. {
  20. Derived d = new Derived();
  21. System.out.println( d.m );
  22. System.out.println( ((Base)d).m );
  23. }
  24. }
Success #stdin #stdout 0.07s 381184KB
stdin
Standard input is empty
stdout
2
1