fork 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. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. B a = new B();
  13. B a2 = new B();
  14. System.out.println(a.getA());
  15. a.setA(250);
  16. System.out.println(a.getA());
  17. System.out.println(a2.getA());
  18. }
  19. }
  20.  
  21. class A
  22. {
  23. protected int a = 20;
  24. }
  25.  
  26. class B extends A
  27. {
  28. public B(){
  29. a = 10;
  30. }
  31.  
  32. public void setA(int ta) {
  33. a = ta;
  34. }
  35.  
  36. public int getA() {
  37. return a;
  38. }
  39. }
Success #stdin #stdout 0.09s 52584KB
stdin
Standard input is empty
stdout
10
250
10