(1)按要求实现下列问题:
1.动物类Animal包含了抽象方法shout();
2.Cat类继承了Animal,并实现方法shout,打印“猫会喵喵叫:喵~”
3.Dog类继承了Animal,并实现方法shout,打印“狗会汪汪叫:汪!”
4.在测试类中实例化对象Animal cat = new Cat(),并调用cat的shout方法
5.在测试类中实例化对象Animal dog = new Dog(),并调用dog的shout方法
public class Test {
public static void main(String[] args) {
Animal cat = new Cat();
cat.shout();
Animal dog = new Dog();
dog.shout();
}
}
abstract class Animal{
abstract void shout();
}
class Cat extends Animal{
public void shout(){
System.out.println("猫会喵喵叫:喵~");
}
}
class Dog extends Animal{
public void shout(){
System.out.println("狗会汪汪叫:汪!");
}
}
(2)创建一个AAA类,私有属性name,里面有局部内部类BBB,私有属性name&#x