代码如下:
//定义抽象类Animal
abstract class Animal {
abstract void shout();
}
//定义Dog类继承抽象类Animal
class Dog extends Animal{
void shout() {
System.out.println("汪汪");
}
}
//定义测试类
class ChouXiang {
public static void main(String[] args) {
Dog dog = new Dog();
dog.shout();
}
}