fork download
  1. class C1 {
  2. public void f ( ) {
  3. System.out.print(" 1 ");
  4. }
  5.  
  6. public void g ( ) {
  7. f ( );
  8. }
  9. }
  10.  
  11. class C2 extends C1 {
  12. public void f ( ) {
  13. System.out.print(" 2 ");
  14. }
  15. }
  16.  
  17. public class Prog {
  18. public static void main(String args[ ]) {
  19. C1 a = new C1( );
  20. a.f( );
  21. C2 b = new C2( );
  22. b.f( );
  23. a = b;
  24. a.f( );
  25. b.g( );
  26. }
  27. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:17: error: class Prog is public, should be declared in a file named Prog.java
                 public class Prog {
                        ^
1 error
stdout

Standard output is empty