fork download
  1. class Ab {
  2. int i = 10;
  3. void getF() {
  4. System.out.println("I am good");
  5. }
  6. }
  7. class Main extends Ab {
  8. int i = 10;
  9. @Override
  10. void getF() {
  11. System.out.println("I am good and bad boy");
  12. }
  13. public static void main(String[] args) {
  14. //Hamm h = new Hamm();
  15. // h.getF(); //Ham
  16. Ab a = new Main(); //reference of parent class
  17. a.getF(); // Ab class
  18.  
  19. }
  20. }
Success #stdin #stdout 0.07s 380160KB
stdin
Standard input is empty
stdout
I am good and bad boy