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. class Base {
  8. public Base(){
  9. }
  10. }
  11.  
  12. class Derived extends Base {
  13. }
  14.  
  15. public class Main
  16. {
  17. public static void main (String[] args)
  18. {
  19. Derived derived = (Derived) new Base();
  20. }
  21. }
  22.  
Runtime error #stdin #stdout #stderr 0.07s 380224KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
Exception in thread "main" java.lang.ClassCastException: Base cannot be cast to Derived
	at Main.main(Main.java:19)