java 继承类 代码有误 求大神

2024-12-28 19:06:33
推荐回答(2个)
回答1:

System.out.println(b.teach() b.study());错误
1.b是老师没有study
2.b.teach()返回void同理a(?).study()void
没有void void的运算
3.System.out.println不能传入参数void
改为
b.teach();
a.study();

回答2:

System.out.println(b.teach()  b.study());

改为

a.study();
b.teach();