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 Greeting
  9. {
  10. public static void main (String[] args)
  11. {
  12. Speak s = new Speak;
  13. s.say();
  14. }
  15. }
  16.  
  17. class Speak {
  18. String name = "Bill";
  19. String greeting = "Hi, ";
  20. void say(){
  21. System.out.println(greeting + name);
  22. }
  23. }
  24.  
  25. class Hello extends Speak {
  26. Hello(){
  27. greeting = "Hello, ";
  28. }
  29. }
  30.  
  31. class Bye extends Speak {
  32. Bye(){
  33. name = "Steve";
  34. greeting = "Bye, ";
  35. }
  36. void shout() {
  37. System.out.println("Bye!! " + name);
  38. }
  39. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:12: error: '(' or '[' expected
		Speak s = new Speak;
		                   ^
1 error
stdout
Standard output is empty