以下程序是接口的实现和测试,请完善程序。Interface Animal { void speak();}( )SeniorAnimal { //接口 void think();}Class Dog implements Animal { public void speak(){ System.out.println("汪汪,汪……"); }} class Person ( ) Animal,SeniorAnimal { //接口实现 public void speak(){ System.out.println("我可以说一句完整的话。"); } public void think(){ System.out.println("我可以思考问题。"); }}Public class Test { public static void main(String] args){ Dog dog=new Dog(); Person p=( ); dog.speak(); p.speak(); p.think(); }}
发布时间:2024-03-31 20:01:56