Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Vehicle {
- void start(){System.out.print("Vehicle: ");}
- }
- class Motorcycle extends Vehicle {
- void second(){System.out.println("Motorcycle: 2nd");}
- }
- class Truck extends Vehicle {
- void third(){System.out.println("Truck: 3rd");}
- }
- class Car extends Vehicle {
- void first(){System.out.println("Car: 1st");}
- }
- class Bike extends Vehicle {
- void fourth(){System.out.println("Bike: 4th");}
- }
- class TestInheritance3{
- public static void main(String[] args){
- Car c=new Car();
- c.start();
- c.first();
- Motorcycle m=new Motorcycle();
- m.start();
- m.second();
- Truck t=new Truck();
- t.start();
- t.third();
- Bike b=new Bike();
- b.start(); b.fourth(); }}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement