格林模拟试题一参考答案

来源:java认证发布时间:2012-11-12 12:47:44java认证视频

 

answer 41)

3) 10 and 40

when a parameter is passed to a method the method receives a copy of the value. the method can modify its value without affecting the original copy. thus in this example when the value is printed out the method has not changed the value.


answer 42)

4) for(int i=0; i< ia.length;i++)

although you could control the looping with a literal number as with the number 4 used in option 3, it is better practice to use the length property of an array. this provides against bugs that might result if the size of the array changes. this question also checks that you know that arrays starts from zero and not one as option 3 starts from one. remember that array length is a field and not a function like the string length() method.


answer 43)

1) error at compile time

this is a slightly sneaky one as it looks like a question about constructors, but it is attempting to test knowledge of the use of the private modifier. a top level class cannot be defined as private. if you didn't notice the modifier private, remember in the exam to be real careful to read every part of the question.


answer 44)

3)10

the name of the class might give you a clue with this question, oct for octal. prefixing a number with a zero indicates that it is in octal format. thus when printed out it gets converted to base ten. 012 in octal means the first column from the right has a value of 2 and the next along has a value of one times eight. in decimal that adds up to 10.


answer 45)

1) error at compile time

the variable i is created at the level of amethod and will not be available inside the method multi. 
 


answer 46)

1) set

the set interface ensures that its elements are unique, but does not order the elements. in reality you probably wouldn't create your own class using the set interface. you would be more likely to use one of the jdk classes that use the set interface such as hashset or treeset.

视频学习

我考网版权与免责声明

① 凡本网注明稿件来源为"原创"的所有文字、图片和音视频稿件,版权均属本网所有。任何媒体、网站或个人转载、链接转贴或以其他方式复制发表时必须注明"稿件来源:我考网",违者本网将依法追究责任;

② 本网部分稿件来源于网络,任何单位或个人认为我考网发布的内容可能涉嫌侵犯其合法权益,应该及时向我考网书面反馈,并提供身份证明、权属证明及详细侵权情况证明,我考网在收到上述法律文件后,将会尽快移除被控侵权内容。

最近更新

社区交流

考试问答