class PrimaryStudent {
protected int grade;
public PrimaryStudent(String name,int age,int score,int grade){
super(name,age,score);
this.grade = grade;
}
public int getGrade(){
return this.grade;
--------------------------------------------------
Main.java:6: error: incompatible types: PrimaryStudent cannot be converted to Student
Student ps = new PrimaryStudent("小军", 9, 100, 5);
^
Main.java:40: error: constructor Object in class Object cannot be applied to given types;
required: no arguments
found: String,int,int
reason: actual and formal argument lists differ in length
2 errors
error: compilation failed
明明跟评论中的大部分答案写的一样啊,怎么会报错呢?
因为你没有继承student
Sign in to make a reply
CarlisWang
class PrimaryStudent {
protected int grade;
public PrimaryStudent(String name,int age,int score,int grade){
super(name,age,score);
this.grade = grade;
}
public int getGrade(){
return this.grade;
}
}
--------------------------------------------------
Main.java:6: error: incompatible types: PrimaryStudent cannot be converted to Student
Student ps = new PrimaryStudent("小军", 9, 100, 5);
^
Main.java:40: error: constructor Object in class Object cannot be applied to given types;
super(name,age,score);
^
required: no arguments
found: String,int,int
reason: actual and formal argument lists differ in length
2 errors
error: compilation failed
明明跟评论中的大部分答案写的一样啊,怎么会报错呢?