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. /*1*/ A a = new A();
  13. /*2*/ B b = new B();
  14. /*3*/ A c = new B();
  15. /*4*/ A d = new B(0);
  16. /*5*/ B e = new B(8);
  17. /*6*/ B.metodaA();
  18. /*7*/ B.metodaB();
  19. /*8*/ B f = new B(-1); f.metodaA();
  20. /*9*/ B g = new B( 0); g.metodaC();
  21. /*10*/ A h = new A(); h.metodaB();
  22. }
  23. }
  24.  
  25. abstract class A {
  26. abstract void metodaA();
  27. void metodaB(){}
  28. }
  29. class B extends A {
  30. private int z;
  31. static void metodaC(){}
  32. void metodaA(){}
  33. B(int i) {
  34. z = i;
  35. }
  36. B(){
  37. z = 0;
  38. }
  39. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:12: error: A is abstract; cannot be instantiated
		   /*1*/ A a = new A();
		               ^
Main.java:17: error: non-static method metodaA() cannot be referenced from a static context
   /*6*/ B.metodaA();
          ^
Main.java:18: error: non-static method metodaB() cannot be referenced from a static context
   /*7*/ B.metodaB();
          ^
Main.java:21: error: A is abstract; cannot be instantiated
  /*10*/ A h = new A();   h.metodaB();
               ^
4 errors
stdout
Standard output is empty