Advertisement
Arnab_Manna

abstraction4.java

Nov 27th, 2021
925
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.43 KB | None | 0 0
  1. abstract class Bike{
  2.     Bike(){System.out.println("bike is created");
  3.     }
  4.     abstract void run();
  5.     void changeGear(){System.out.println("gear is changed");}
  6. }
  7.  
  8. class Honda extends Bike{
  9.     void run(){System.out.println("running safely");}
  10. }
  11.  
  12. class TestAbstraction2{
  13.         public static void main(String args[]){
  14.             Bike obj=new Honda();
  15.             obj.run();
  16.             obj.changeGear();
  17.         }
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement