publisabstractclassCar{
privateststicfinalintcar_number;
publicgetCar_number();
publicsetCar_number();
}
publicclassTrashCarestendsCar{
privateStringcapacity;
publicgetCapacity();
publicsetCapacity();
publicstaticvoidmain(String[]args){
TrashCartrashCar=newTrashCar();
}
}
注:car一般是抽象类不能实力化。只能被继承car是把所有车比如卡车、轿车、吉普车、面包车等抽象成的类。