package baidu; public abstract class test_abstract { private String name; test_abstract(String name){ this.name = name; } public abstract void enjoy(); } package baidu; public class test_Dog extends test_abstract{ test_Dog(String name) { super(name); } @Override public void enjoy() { System.out.println("小狗汪汪。。。"); } } package baidu; //继承抽象类 public class test_Cat extends test_abstract{ private String eyesColour; test_Cat(String name, String eyesColour) { super(name); this.eyesColour = eyesColour; } @Override public void enjoy() { System.out.println(eyesColour + "猫咪O(∩_∩)O哈哈~"); } } package baidu; import java.io.IOException; import org.junit.Test; public class test_baiduString { @Test public void test2() { test_Cat cat = new test_Cat("mimi", "white"); test_Dog dog = new test_Dog("泰迪狗"); cat.enjoy(); dog.enjoy(); } }