【发布时间】:2018-06-27 02:52:30
【问题描述】:
package implementation;
public abstract class Student {
String name; int standard;
abstract void getPercentage();
static void getTotalNoOfStudents() {}
public Student() {}
public Student(String name, int standard) {
this.name=name; this.standard=standard;
}
}
public class ScienceStudent extends Student {
int ScienceMarks;
public static int noOfStudents=0;
public ScienceStudent(String name, int standard, int ScienceMarks) {
super(name, standard);
this.ScienceMarks=ScienceMarks;
}
public void getPercentage() {
System.out.println(10000/ScienceMarks);
}
}
public class HistoryStudent extends Student {
int historyMarks;
public static int noOfStudents;
public HistoryStudent(String name, int standard, int historyMarks) {
super(name, standard);
this.historyMarks=historyMarks;
}
public void getPercentage() {
System.out.println(10000/historyMarks);
}
}
public class AllStudent {
public static void main(String[] args) {
ScienceStudent abhi = new ScienceStudent("Abhishek",2,95);
HistoryStudent raj = new HistoryStudent("Rajath",2,80);
abhi.getPercentage();
raj.getPercentage();
}
}
我在“AllStudent”类中遇到“隐式超级构造函数 Student() 未定义默认构造函数。必须定义显式构造函数。搜索差异答案,但没有任何帮助理解和纠正问题。 它还说“AllStudent 类型必须实现继承的抽象方法 Student.getPercentage(); 有人可以解决这个问题并解释我应该做些什么来纠正这个问题。
【问题讨论】:
标签: java