Advertisement
Guest User

Untitled

a guest
Jan 15th, 2020
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  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(); }}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement