Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/313.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 获取错误“;默认构造函数的隐式超级构造函数Student()未定义。必须定义一个显式构造函数;_Java - Fatal编程技术网

Java 获取错误“;默认构造函数的隐式超级构造函数Student()未定义。必须定义一个显式构造函数;

Java 获取错误“;默认构造函数的隐式超级构造函数Student()未定义。必须定义一个显式构造函数;,java,Java,我在“AllStudent”类中发现一个错误,即“默认构造函数的隐式超级构造函数Student()未定义。必须定义显式构造函数。搜索了不同的构造函数,但对理解和纠正问题没有任何帮助。 它还说,“类型AllStudent必须实现继承的抽象方法Student.getPercentage(); 有人能解决这个问题并向我解释我应该怎么做来纠正这个问题。你的代码格式不正确。您的代码存在以下问题: 行中缺少包实现和int ScienceMarks 每个类都缺少右括号} HistoryStudent类缺少c

我在“AllStudent”类中发现一个错误,即“默认构造函数的隐式超级构造函数Student()未定义。必须定义显式构造函数。搜索了不同的构造函数,但对理解和纠正问题没有任何帮助。 它还说,“类型AllStudent必须实现继承的抽象方法Student.getPercentage();
有人能解决这个问题并向我解释我应该怎么做来纠正这个问题。

你的代码格式不正确。您的代码存在以下问题:

  • 行中缺少
    包实现
    int ScienceMarks
  • 每个类都缺少右括号
    }
  • HistoryStudent
    类缺少
    class
    关键字
下面是更正的代码。看到它工作了吗


投票被否决,因为你没有解释你改变了什么以及为什么需要改变。(我甚至没有发现…)JacobWood更新了解释,很快就改变了投票。
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();
   }
}
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();
}
}