【发布时间】:2015-02-23 14:11:00
【问题描述】:
其实我不明白无参数构造函数和默认构造函数有什么区别。
import javax.swing.*;
public class Test extends JFrame {
public Test() {
super();
this.setSize(200,200);
this.setVisible(true);
}
public static void main(Sting[] arg) {
Test cFrame = new Test();
}
}
在创建名为 cFrame 的 Test 对象时,是否会调用此类的默认构造函数?
【问题讨论】:
-
不,它不会调用默认构造函数,现在没有默认构造函数
-
我的两分钱:默认构造函数只能调用基类的无参数构造函数。
标签: java constructor default-constructor