Advertisement
andrefecto

Untitled

May 4th, 2015
252
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.47 KB | None | 0 0
  1. class Vehicle{
  2.     public void move(){
  3.     System.out.println(“Vehicles can move!!);
  4.     }
  5. }
  6. class MotorBike extends Vehicle{
  7.     public void move(){
  8.     System.out.println(“MotorBike can move and accelerate too!!);
  9.     }
  10. }
  11. class Test{
  12.     public static void main(String[] args){
  13.     Vehicle vh=new MotorBike();
  14.     vh.move();    // prints MotorBike can move and accelerate too!!
  15.     vh=new Vehicle();
  16.     vh.move();    // prints Vehicles can move!!
  17.     }
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement