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. // your code goes here
  13. A a = new A();
  14. B b = new B();
  15. a.inc();
  16. a.inc();
  17. b.inc();
  18. System.out.println(a.get());
  19. System.out.println(b.get());
  20. }
  21. }
  22. class Parent
  23. {
  24. private int test = 0;
  25. public void inc()
  26. {
  27. test++;
  28. }
  29. public int get()
  30. {
  31. return test;
  32. }
  33. }
  34. class A extends Parent
  35. {
  36. public A()
  37. {
  38. }
  39. }
  40. class B extends Parent
  41. {
  42. public B()
  43. {
  44. }
  45. }
Success #stdin #stdout 0.09s 52536KB
stdin
Standard input is empty
stdout
2
1