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 Parent {
  8.  
  9. public void run() {
  10. System.out.println("You are a parent");
  11. }
  12. }
  13.  
  14. class Child extends Parent {
  15.  
  16. @Override
  17. public void run() {
  18. System.out.println("You are a child");
  19. }
  20. }
  21.  
  22.  
  23. class Test {
  24. public static void main(String[] args) {
  25. Parent child = new Child();
  26. child.run(); // <- prints "you are a child"
  27. }
  28. }
  29.  
Success #stdin #stdout 0.08s 32592KB
stdin
Standard input is empty
stdout
You are a child