相关疑难解决方法(0)

为什么派生类构造函数总是访问基类构造函数?

我在我的一篇试卷中看到了这个问题:

为什么派生类构造函数总是访问基类构造函数?

我想知道这个问题是否有效?

java base-class derived-class

3
推荐指数
1
解决办法
988
查看次数

无法实现构造函数(隐式超级构造函数Item()未定义)

我正在尝试实现具有比父类更多参数的类的构造函数,唯一的共同点是标题.当我尝试在Book类中实现构造函数时,它向我显示错误"隐式超级构造函数Item()未定义".

public class Book extends Item {

private String author = "";
private String ISBN = "";
private String publisher = "";

public Book(String theTitle, String theAuthor, String theIsbn, String thePublisher){

}
Run Code Online (Sandbox Code Playgroud)

}

父类构造函数;

public abstract class Item {

private String title;
private int playingTime;
protected boolean gotIt;
private String comment;

public Item(String title, int playingTime, boolean gotIt, String comment) {
    super();
    this.title = title;
    this.playingTime = playingTime;
    this.gotIt = gotIt;
    this.comment = comment;
}
Run Code Online (Sandbox Code Playgroud)

提前致谢.

java constructor superclass

0
推荐指数
1
解决办法
551
查看次数