请教一个关于java的英文题目.“1.Which of the following stat”1.Which of the following statements is true about constructors?a) A constructor must be listed straight after the fields.b) A constructor must have no parameters.c) A class can have only one constructor.d) A class can have any number of constructors.e) A constructor returns a pointer to the class.1d 能不能简单说明一下为什么其他的选项不对?
问题描述:
请教一个关于java的英文题目.“1.Which of the following stat”
1.Which of the following statements is true about constructors?
a) A constructor must be listed straight after the fields.
b) A constructor must have no parameters.
c) A class can have only one constructor.
d) A class can have any number of constructors.
e) A constructor returns a pointer to the class.
1d
能不能简单说明一下为什么其他的选项不对?
答
a)构造方法必须被直接在字段后列出来.(可以在最前面.)
b) 构造方法必须没有参数.(可以无参、可以有参.)
c) 一个类只能有一个构造方法.(可以一个、可以有多个、也可以没有.)
d) 一个类能有好几个构造方法.(对)
e)构造方法返回一个指针给类.(通常是初始化各种数据,不会返回一个指针.)