JAVA认证格林模拟试题二答案及解析
来源:优易学  2009-11-28 15:39:39   【优易学:中国教育考试门户网】   资料下载   IT书店
文章页内部300*250广告位

 

answer 41)

1) b=m;
3) d =i;

you can assign up the inheritance tree from a child to a parent but not the other way without an explicit casting. a boolean can only ever be assigned a boolean value.


answer 42)

2) you can obtain a mutually exclusive lock on any object
3) a thread can obtain a mutually exclusive lock on an object by calling a synchronized method on that object.
4) thread scheduling algorithms are platform dependent

yes that says dependent and not independent.

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.

answer 48)

2)s+=i;

only a string acts as if the + operator were overloaded


answer 49)

although the objectives do not specifically mention the need to understand the i/o classes, feedback from people who have taken the exam indicate that you will get questions on this topic. as you will probably need to know this in the real world of java programming, get familiar with the basics. i have assigned these questions to objective 10.1 as that is a fairly vague objective.

1) file f = new file("/","autoexec.bat");
2) datainputstream d = new datainputstream(system.in);
3) outputstreamwriter o = new outputstreamwriter(system.out);

option 4, with the randomaccess file will not compile because the constructor must also be passed a mode parameter which must be either "r" or "rw"


answer 50)

1)o1=o2;

2)b=ob;

4)o1=b;


上一页  [1] [2] [3] [4] [5] [6] 下一页

责任编辑:小草

收藏此页】【 】【打印】【回到顶部
计算机文章页底部500*200广告
文章搜索:
 相关文章
计算机底部580*90广告
文章页右侧第一330*280广告
计算机文章页资讯推荐
热点资讯
文章页330尺寸谷歌广告位
热门课程培训