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

标签 java

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

相关文章:

java - Android 应用程序无法正确渲染阿拉伯语字体

java - 使用来自 Hibernate 实体的现有数据填充 envers 修订表

java - 从另一个表插入 db2 表并拥有自己的值

java - 如何通过 spring @RestController 提供压缩文件下载?

java - 日期格式验证不适用于 yyyy-MM-dd

java - 如何从请求Spring Boot转换dataTable

java - Java似乎无法识别正斜杠

java - 以相反顺序对数组进行排序 - 不反转

java - 如何使用 HashMap 模拟我的 Mongodb 存储库

java - 使用PreparedStatement setNull