fork download
  1.  
  2.  
  3. class Shape{
  4. public void disp(){
  5. System.out.println("Disp in Shape class");
  6. }
  7. }
  8.  
  9. class Rectangle extends Shape{
  10. public void disp(){
  11. System.out.println("Disp in Rectangle class");
  12. }
  13. }
  14.  
  15. class Example{
  16. public static void main(String args[]){
  17. Shape obj=new Rectangle();
  18. obj.disp();
  19. Rectangle rect=new Rectangle();
  20. rect.disp();
  21. }
  22. }
  23.  
Success #stdin #stdout 0.09s 54604KB
stdin
Standard input is empty
stdout
Disp in Rectangle class
Disp in Rectangle class