SHARE
TWEET

Untitled

a guest Jan 15th, 2020 67 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class Vehicle {
  2.   void start(){System.out.print("Vehicle: ");}
  3.   }
  4. class Motorcycle extends Vehicle {
  5.  void second(){System.out.println("Motorcycle: 2nd");}
  6. }
  7. class Truck extends Vehicle {
  8.  void third(){System.out.println("Truck: 3rd");}
  9. }
  10. class Car extends Vehicle {
  11.   void first(){System.out.println("Car: 1st");}
  12. }
  13. class Bike extends Vehicle {
  14.  void fourth(){System.out.println("Bike: 4th");}
  15. }
  16. class TestInheritance3{
  17.     public static void main(String[] args){
  18.         Car c=new Car();
  19.         c.start();
  20.         c.first();
  21.         Motorcycle m=new Motorcycle();
  22.         m.start();
  23.         m.second();
  24.         Truck t=new Truck();
  25.         t.start();
  26.         t.third();
  27.         Bike b=new Bike();
  28.         b.start();  b.fourth(); }}
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top