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

 

answer 21)

1,2

value for i=1 value for j=1
value for i=2 value for j=1
 

the statement continue outer causes the code to jump to the label outer and the for loop increments to the next number.


answer 22)

4) runtime error, an exception will be thrown

a call to wait/notify must be within synchronized code. with jdk1.2 this code throws the error message

java.lang.illegalmonitorstateexception: current thread not owner
at java.lang.object.wait(native method)
at java.lang.object.wait(object.java:424)
at dsross.notwait(compiled code)
at dsross.run(agg.java:21)


answer 23)

2,3

options 1, & 4 will not compile as they attempt to throw exceptions not declared in the base class. because options 2 and 3 take a parameter of type long they represent overloading not overriding and there is no such limitations on overloaded methods.

answer 24)

3) system.out.println(math.ceil(-4.7));

options 1 and 2 will produce -5 and option 4 will not compile because the min method requires 2 parameters.
 


answer 25)

3) compile time error

the wrapper classes cannot be used like primitives.

depending on your compiler you will get an error that says someting like "error: can't convert java lang integer". wrapper classes have similar names to primitives but all start with upper case letters.

thus in this case we have int as a primitive and integer as a wrapper. the objectives do not specifically mention the wrapper classes but don't be surprised if they come up.


answer 26)

2) ic

this is a bit of a catch question. anyone with a c/c++ background would figure out that addressing in strings starts with 0 so that 1 corresponds to i in the string bicycle. the catch is that the second parameter returns the endcharacter minus 1. in this case it means instead of the "icy" being returned as intuition would expect it is only "ic".


answer 27)

3) s.indexof('v');

charat returns the letter at the position rather than searching for a letter and returning the position, mid is just to confuse the basic programmers, indexof(s,'v'); is how some future vb/j++ nightmare hybrid, might perform such a calculation.


answer 28)

1) s3=s1 + s2;

java does not allow operator overloading as in c++, but for the sake of convenience the + operator is overridden for strings.


answer 29)

4) 7

the | is known as the or operator, you could think of it as the either/or operator. turning the numbers into binary gives

4=100

3=011

for each position, if either number contains a 1 the result will contain a result in that position. as every position contains a 1 the result will be

111

which is decimal 7.

answer 30)

1,2,3

public, private, static are all legal access modifiers for this inner class.


 

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

责任编辑:小草

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