fork(2) download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6. class MyException extends Exception {}
  7. class A {
  8. protected void m() throws MyException {
  9. System.out.println("A");
  10. }
  11. }
  12. class B extends A {
  13. public void m() {
  14. System.out.println("B");
  15. }
  16. }
  17. /* Name of the class has to be "Main" only if the class is public. */
  18. class Ideone
  19. {
  20. public static void main (String[] args)
  21. {
  22. A a = new B();
  23. ((B)a).m();
  24. }
  25. }
Success #stdin #stdout 0.09s 320576KB
stdin
Standard input is empty
stdout
B