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. AA a = new AA();
  13. BB b = new BB();
  14.  
  15. System.out.println(a.functionFromBase() + " " + b.functionFromBase() );
  16. System.out.println(a.functionFromA() + " " + b.functionFromB() );
  17. System.out.println(a.functionFromCommon() + " " + b.functionFromCommon());
  18. }
  19. }
  20.  
  21. class Base {
  22. public int functionFromBase() {
  23. return 0;
  24. }
  25. }
  26.  
  27. class A extends Base {
  28. public int functionFromA() {
  29. return 1;
  30. }
  31. }
  32.  
  33. class B extends Base {
  34. public int functionFromB() {
  35. return 2;
  36. }
  37. }
  38.  
  39. interface Common {
  40. default int functionFromCommon() {
  41. return 7;
  42. }
  43. }
  44.  
  45. class AA extends A implements Common {}
  46. class BB extends B implements Common {}
  47.  
Success #stdin #stdout 0.04s 711168KB
stdin
Standard input is empty
stdout
0 0
1 2
7 7