gpt4 book ai didi

java - 过去关于构造函数的 Java 考试

转载 作者:塔克拉玛干 更新时间:2023-11-03 03:38:40 25 4
gpt4 key购买 nike

我正在参加过去的 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com