若父类为Human,代码如下public abstract class Human { public String name; public int age; public abstract void say();public String toString() { return "Human [name=" + name + ", age=" + age + "]";}}子类如下,public class Chinese extends Human { String name = "小明"; int age = 15; public void say() { System.out.println("讲国语"); } public String toString() { return "Chinese [age=" + age + "]"; } }测试类public class test { public static void main(String[] args) { Human one = new Human();//为什么这一行就报错了呢? one.say(); Human man= new Chinese(); System.out.println(man); }}
添加回答
举报
0/150
提交
取消