fork download
  1.  
  2. class Person {
  3.  
  4. void role() {
  5. System.out.println("I don't do anything.");
  6. }
  7. void country() {
  8. System.out.println("I live in Bangladesh.");
  9. }
  10.  
  11. }
  12.  
  13.  
  14. class GoodPerson extends Person {
  15.  
  16. void role() {
  17. System.out.println("I'll help you");
  18. }
  19. }
  20.  
  21. class BadPerson extends Person {
  22.  
  23. @Override
  24. void role() {
  25. System.out.println("I'll kill you.");
  26. }
  27. }
  28.  
  29. public class Main {
  30. public static void main(String[] args) {
  31.  
  32.  
  33. Person p = new GoodPerson();
  34.  
  35. p.role();
  36. p.country();
  37. }
  38. }
Success #stdin #stdout 0.12s 54584KB
stdin
Standard input is empty
stdout
I'll help you
I live in Bangladesh.