课后作业这样做对吗?
public class Traffic { int people; String tra; public void run(){ System.out.println(people+"人乘坐"+tra+"出行"); } }
public class Car extends Traffic { {super.people=40; super.tra="大巴"; } public Car(){ super.run(); } }
public class Test { public static void main(String[] args){ Traffic T = new Traffic(); Car c = new Car(); } }
输出的结果是对的,但总觉得怪怪的,请教下各位大神,这样做有问题吗?