tampurus

34 Function(Method) overriding

May 2nd, 2022 (edited)
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.40 KB | None | 0 0
  1. class Vehicle{  
  2.     void run()
  3.     {
  4.       System.out.println("Vehicle is running");}  
  5.     }  
  6. class Bike2 extends Vehicle
  7. {  
  8.     void run()
  9.     {
  10.         System.out.println("Bike is running safely");
  11.     }  
  12.     public static void main(String args[]){  
  13.         Bike2 obj = new Bike2();//creating object  
  14.         obj.run();//calling method  
  15.     }  
  16. }
  17. // output
  18. Bike is running safely
Add Comment
Please, Sign In to add comment