Write the java program in the following features of OOP:
1,Encapsulation
2,Polymorphism
3,Inheritance
4,Abstraction
public abstract class Vehicle {
    private String color;
    public Vehicle(String color) {
        this.color = color;
    }
    public abstract void useHorn();
}public class Car extends Vehicle {
    private String frontLicensePlate;
    private String rearLicensePlate;
    public Car(String color) {
        super(color);
    }
    @Override
    public void useHorn() {
        System.out.println("Bip-bip");
    }
    public void addLicensePlate(String frontLicensePlate, String rearLicensePlate) {
        this.frontLicensePlate = frontLicensePlate;
        this.rearLicensePlate = rearLicensePlate;
    }
    public void addLicensePlate(String licensePlate) {
        frontLicensePlate = licensePlate;
        rearLicensePlate = licensePlate;
    }
}
Comments