JAVA中,构造器在一个对象被 new时执行;一个类中能定义一个构造器,这两句话都有错吗?
补充:漏了一个字了,一个类中只能定义一个构造器,现在在知道答案了,这是错的,构造器可以重载的嘛。呵呵。。...
补充:漏了一个字了,一个类中只能定义一个构造器,现在在知道答案了,这是错的,构造器可以重载的嘛。呵呵。。
展开
5个回答
展开全部
1. A constructor is called when a 'new' expression is evaluated. This is true. This is the only way to construct an object, if we do not consider Java reflection.
2. You can only define one constructor in a class. This is false. You can define multiple constructors, as long as their parameters are different, just like you can define multiple functions with the same name. The arguments passed to the 'new' expression determine which constructor to call. You can also mix private and public constructors.
2. You can only define one constructor in a class. This is false. You can define multiple constructors, as long as their parameters are different, just like you can define multiple functions with the same name. The arguments passed to the 'new' expression determine which constructor to call. You can also mix private and public constructors.
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2012-07-18
展开全部
没有的
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
没错
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
没有错
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询