抽象类本身并不能被引用,但是可以被作为父类继承
接口实在原有的继承上再去添加新的功能 比如:
abstract class Car{
public abstract void start();
public abstract void stop();
}
interface Alarm{
public void sound();
}
class BydCar extends Car{
@Override
public void start() {
// TODO Auto-generated method stub
}
@Override
public void stop() {
// TODO Auto-generated method stub
}}
class AudiCar extends Car{
@Override
public void start() {
// TODO Auto-generated method stub
}
@Override
public void stop() {
// TODO Auto-generated method stub
}}
class LandRoverCar extends Car implements Alarm{
@Override
public void sound() {
// TODO Auto-generated method stub
}
@Override
public void start() {
// TODO Auto-generated method stub
}
@Override
public void stop() {
// TODO Auto-generated method stub
}}