constructor必须与class同名,但方法不能与class同名?

炜大2022-10-04 11:39:541条回答

constructor必须与class同名,但方法不能与class同名?
3.下列说法正确的有( )
A. class中的constructor不可省略
B. constructor必须与class同名,但方法不能与class同名
C. constructor在一个对象被new时执行
D. 一个class只能定义一个constructor
请问B选项对不对

已提交,审核后显示!提交回复

共1条回复
dg323 共回答了20个问题 | 采纳率85%
B不对啊,方法可以和class同名
1年前

相关推荐

Implicit super constructor People() is undefined.Must explic
Implicit super constructor People() is undefined.Must explicitly invoke another constructor
匿名人氏1年前1
飞天老鼎 共回答了23个问题 | 采纳率78.3%
应该是在父类当中没有无参构造,在People类中加入一句
public People(){}
应该就可以了
请分析此句英文的语法结构Note that the constructor is not explicit,which
请分析此句英文的语法结构
Note that the constructor is not explicit,which would make typical uses of any awkward and would not impart additional safety.
翻译:
注意,该构造函数不是 explicit 的,如果是的话,any 会难以使用,而且也不会增加安全性.
根据我自己的语法知识,认为which是修饰the constructor is not explicit这句话的,但是查看翻译,发现which却是修饰explicit的,难道which可以修饰形容词?(而且通过上下文,翻译是正确的)
我问题中给出了中文版的正确翻译(不是我翻译的,是书里面的),而且经过上下文分析,翻译的对的。我现在想弄明白的是为什么会翻译成这样?英文里面有没有which修饰形容词的情况?或者中文翻译是一种理解后的翻译,并非一字一句的翻译?
土豆丝清炒1年前3
ficholas 共回答了24个问题 | 采纳率87.5%
其实,首先要明白一个概念,就是什么事 "定语" 可能,很多人都知道,定语就是起形容词修饰 作用的.那么什么样的词可以起形容词作用?可能很多人都狭隘得定义为 "形容词作定语".但是,我们知道,形容词可以作定语,名词也可以作定语,非谓语动词也可以作定语!例如 book shop 在这里就是名词修饰名词 walking stick 这个就是动名词作定语 used book 这里是过去分词作定语,deep green 这里是形容词修饰形容词
你写的这个句子,note 是动词,that the constructor is not explicit是宾语从句,which would make typical uses of any awkward and would not impart additional safety.是一个非限制性定语从句,修饰的不是explicit,而是整个句子!
定语从句,需要一个先行词,先行词往往是一个名词,代词,但是非限制性定语从句,可以修饰整个句子!和which一样用法的,还有一个as,例如,Tom got the first prize in the game ,as was expected !Tom在比赛中得了第一名,正如被期望的一样.这个句子中,as引导非限制性定语从句,修饰整个句子!当然,as和which 在具体用法上也是有区别的:
1 as 可以用于定语从句的句首句中句尾,which 只能放主句之后
2 as用于被动语态和表示习惯性用法的句子,例如:I go to work by bus every day ,as many people do .和许多人一样,我每天都坐公交车上班.表示习惯性和司空见惯行为.
,Tom got the first prize in the game ,as was expected !Tom在比赛中得了第一名,正如被期望的一样.这里就是被动表达了.
3 which 用于否定结构,以及符合宾语结构中,例如:
Our football team lost the game ,which we didn't expect .我们的足球队输了,这是我们不希望发生的.(否定结构)
He always speaks highly of Lucy in the play ,which makes others upset.他总是高度赞扬Lucy在戏剧中的角色,这使得其他人很不安!(复合宾语结构)
请分析此句英文的语法结构Note that the constructor is not explicit,which
请分析此句英文的语法结构
Note that the constructor is not explicit,which would make typical uses of any awkward and would not impart additional safety.
翻译:
注意,该构造函数不是 explicit 的,如果是的话,any 会难以使用,而且也不会增加安全性.
根据我自己的语法知识,认为which是修饰the constructor is not explicit这句话的,但是查看翻译,发现which却是修饰explicit的,难道which可以修饰形容词?(而且通过上下文,翻译是正确的)
我问题中给出了中文版的正确翻译(不是我翻译的,是书里面的),而且经过上下文分析,翻译的对的。我现在想弄明白的是为什么会翻译成这样?英文里面有没有which修饰形容词的情况?或者中文翻译是一种理解后的翻译,并非一字一句的翻译?
当爱情掠过1年前3
631212 共回答了15个问题 | 采纳率93.3%
其实,首先要明白一个概念,就是什么事 "定语" 可能,很多人都知道,定语就是起形容词修饰 作用的.那么什么样的词可以起形容词作用?可能很多人都狭隘得定义为 "形容词作定语".但是,我们知道,形容词可以作定语,名词也可以作定语,非谓语动词也可以作定语!例如 book shop 在这里就是名词修饰名词 walking stick 这个就是动名词作定语 used book 这里是过去分词作定语,deep green 这里是形容词修饰形容词
你写的这个句子,note 是动词,that the constructor is not explicit是宾语从句,which would make typical uses of any awkward and would not impart additional safety.是一个非限制性定语从句,修饰的不是explicit,而是整个句子!
定语从句,需要一个先行词,先行词往往是一个名词,代词,但是非限制性定语从句,可以修饰整个句子!和which一样用法的,还有一个as,例如,Tom got the first prize in the game ,as was expected !Tom在比赛中得了第一名,正如被期望的一样.这个句子中,as引导非限制性定语从句,修饰整个句子!当然,as和which 在具体用法上也是有区别的:
1 as 可以用于定语从句的句首句中句尾,which 只能放主句之后
2 as用于被动语态和表示习惯性用法的句子,例如:I go to work by bus every day ,as many people do .和许多人一样,我每天都坐公交车上班.表示习惯性和司空见惯行为.
,Tom got the first prize in the game ,as was expected !Tom在比赛中得了第一名,正如被期望的一样.这里就是被动表达了.
3 which 用于否定结构,以及符合宾语结构中,例如:
Our football team lost the game ,which we didn't expect .我们的足球队输了,这是我们不希望发生的.(否定结构)
He always speaks highly of Lucy in the play ,which makes others upset.他总是高度赞扬Lucy在戏剧中的角色,这使得其他人很不安!(复合宾语结构)
/** Write a class Square whose constructor receives the leng
/** Write a class Square whose constructor receives the length of the sides.
Then supply methods to compute the
area and perimeter of the square.
Also compute the length of the diagonal using the Pythagorean Theorem.
Use the following class as a template your tester class
*/
public class Square {
x05 public Square(double sideLength)
x05 {
x05x05Square mySquare = new Square();
x05 }
x05 public double getArea()
x05 {
x05x05double area = sideLength * sideLength;
x05x05return area;
x05 }
x05 public double getPerimeter()
x05 {
x05x05double perimeter = 4 * sideLength;
x05x05return perimeter;
x05 }
x05 public double getDiagonalLength()
x05 {
x05x05double diagonal = Math.sqrt(sideLength * sideLenght + sideLength * sideLength);
x05x05return diagonal;
x05 }
}
Square mySquare = new Square();
error:constructor Square in class Square cannot be applied to given types;
double area = sideLength * sideLength;
error:cannot find symbol
double perimeter = 4 * sideLength;
error:cannot find symbol
double diagonal = Math.sqrt(sideLength * sideLenght + sideLength * sideLength);
error:cannot find symbol
anyone can help?
thx sooo much
我另外两个程序也都有 cannotfindsymbol的问题 到底应该怎样啊
路竹1年前1
芝麻萤4 共回答了22个问题 | 采纳率95.5%
如果你的程序这么写,那么很明显你的后面的方法中使用的sideLength没有定义
你在外面加个double sideLength;就可以了.因为你在第一个构造方法中定义了double sideLength它只能在它那个方法里面用,所以你必须定义一个double sideLength为全局变量,后面的就不会报错了
装修工的英文是什么我指的是对家庭进行翻新,装修的装修工,不是constructor,这个是建筑工人,专门盖楼的,不一样的
帝乡韵味1年前4
忠林 共回答了16个问题 | 采纳率81.3%
fitment worke