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.  
  8. abstract class AbstractClass {
  9. abstract void methodA();
  10. }
  11.  
  12. class ChildClass1 extends AbstractClass {
  13. void methodA() {
  14. // Implementation for methodA
  15. System.out.println("I am ChildClass1's methodA");
  16. }
  17. }
  18.  
  19. class ChildClass2 extends ChildClass1 {
  20. // No implementation for methodA
  21. }
  22.  
  23. class ChildClass3 extends ChildClass2 {
  24. // No implementation for methodA
  25. }
  26.  
  27. /* Name of the class has to be "Main" only if the class is public. */
  28. class Ideone
  29. {
  30. public static void main (String[] args) throws java.lang.Exception
  31. {
  32.  
  33. ChildClass1 object1 = new ChildClass1();
  34. ChildClass1 object2 = new ChildClass2();
  35. ChildClass3 object3 = new ChildClass3();
  36.  
  37. object1.methodA();
  38. object2.methodA();
  39. object3.methodA();
  40. }
  41. }
Success #stdin #stdout 0.09s 37696KB
stdin
Standard input is empty
stdout
I am ChildClass1's methodA
I am ChildClass1's methodA
I am ChildClass1's methodA