格林模拟试题二参考答案

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

 

answer 43)

2) ask for a re-design of the hierarchy with changing the operating system to a field rather than class type

this question is about the requirement to understand the difference between the "is-a" and the "has-a" relationship. where a class is inherited you have to ask if it represents the "is-a" relationship. as the difference between the root and the two children are the operating system you need to ask are linux and windows types of computers.the answer is no, they are both types of operating systems. so option two represents the best of the options. you might consider having operating system as an interface instead but that is another story.

of course there are as many ways to design an object hierarchy as ways to pronounce bjarne strousjoup, but this is the sort of answer that sun will proabably be looking for in the exam. questions have been asked in discussion forums if this type of question really comes up in the exam. i think this is because some other mock exams do not contain any questions like this. i assure you that this type of question can come up in the exam. these types of question are testing your understanding of the difference between the is-a and has-a relationship in class design.


answer 44)

1) an inner class may be defined as static
4) an inner class may extend another class

a static inner class is also sometimes known as a top level nested class. there is some debate if such a class should be called an inner class. i tend to think it should be on the basis that it is created inside the opening braces of another class. how could a programmer provide a constructor for an anonymous class?. remember a constructor is a method with no return type and the same name as the class. inner classes may be defined as private


answer 45

4) compilation and output of "not equal! 10"

the output will be "not equal 10".  this illustrates that the output +=10 calculation was never performed because processing stopped after the first operand was evaluated to be false. if you change the value of b1 to true processing occurs as you would expect and the output is "we are equal 20";.


answer 46)

2)j= i<<j;

4)j=i<<l;

answer 47)

4) 12

as well as the binary or objective this questions requires you to understand the octal notation which means that the leading letter zero (not the letter o)) means that the first 1 indicates the number contains one eight and nothing else. thus this calculation in decimal mean

8|4

to convert this to binary means

1000

0100

----

1100

----

which is 12 in decimal

the | bitwise operator means that for each position where there is a 1, results in a 1 in the same position in the answer.

视频学习

我考网版权与免责声明

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

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

最近更新

社区交流

考试问答