我正在参加过去的 Java 考试,但有一个问题一直困扰着我。
问题是:“任何构造函数显式或自动调用其父类的构造函数,父类调用其父类,依此类推类层次结构。这个过程的名称是什么?
感谢您的回答!
最佳答案
这叫做“构造函数链”
@编辑:添加来源:Oracle's documentation .由 Oli Charlesworth 提供。
If a subclass constructor invokes a constructor of its superclass, either explicitly or implicitly, you might think that there will be a whole chain of constructors called, all the way back to the constructor of Object. In fact, this is the case. It is called constructor chaining, and you need to be aware of it when there is a long line of class descent.
关于java - 过去关于构造函数的 Java 考试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19477767/