fork(1) download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8.  
  9. class A {
  10. private int i = 1;
  11.  
  12. public int getI(){ return this.i ; }
  13. }
  14.  
  15. class B extends A {
  16. private int i = 2;
  17.  
  18. public int getIdeUmJeitoDiferente(){ return this.i ; }
  19. }
  20.  
  21.  
  22.  
  23. class Ideone
  24. {
  25. public static void main (String[] args) throws java.lang.Exception
  26. {
  27. B b = new B();
  28.  
  29. System.out.println("b.getI=" + b.getI() + ", b.getIdeUmJeitoDiferente=" + b.getIdeUmJeitoDiferente());
  30. }
  31. }
Success #stdin #stdout 0.11s 320576KB
stdin
Standard input is empty
stdout
b.getI=1, b.getIdeUmJeitoDiferente=2