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

 

answer 31)

3) output of first0, first1, second0, second1

note that this code overrides and calls the start method. if you wished to get the output mixed you would need to override the run method but call the start method.


answer 32) 

2) setlayout(new gridlayout(2,2));
 

changing the layout manager is the same for an applet or an application. answer 1 is wrong though it might have been a reasonable name for the designers to choose. answers 3 and 4 are incorrect because changing the layout manager always requires an instance of one of the layout managers and these are bogus methods.

instead of creating the anonymous instance of the layout manager as in option 2 you can also create a named instance and pass that as a parameter. this is often what automatic code generators such as borland/inprise jbuilder do.


answer 33)

3) the code will cause an error at compile time

the error is caused because run should have a void not an int return type.

any class that is implements an interface must create a method to match all of the methods in the interface. the runnable interface has one method called run that has a void return type.the sun compiler gives the error

method redefined with different return type: int run() was defined as void run();
 


answer 34)


3) compilation and output of 0 followed by 1

the creation of an anonymous class as a parameter to go is fairly strange as you would expect it to override a method in its parent class (turing). you don't have to though. the fact that class turing extends thread means the anonymous instance that is passed to go has a start method which then calls the run method.

answer 35)

4) compile time error
 

the only operator overloading offered by java is the + sign for the string class. a char is a 16 bit integer and cannot be concatenated to a string with the + operator.


answer 36)

3) if(s.equalsignorecase(s2))

string comparison is case sensitive so using the equals string method will not return a match. using the==operator just compares where memory address of the references and nocasematch was just something i made up to give me a fourth slightly plausible option.


answer 37)

1) s.setbackground(color.pink);

for speakers of the more british spelt english note that there is no letter u in color. also the constants for colors are in lower case.


answer 38)

4) the file class does not support directly changing the current directory.

this seems rather surprising to me, as changing the current directory is a very common requirement. you may be able to get around this limitation by creating a new instance of the file class passing the new directory to the constructor as the path name.


answer 39)

1)with a fixed font you will see 5 characters, with a  proportional it will depend on the width of the characters

with a proportional font the letter w will occupy more space than the letter i. so if you have all wide characters you may have to scroll to the right to see the entire text of a textfield.


answer 40)

3) on the line after //two put super(10);

constructors can only be invoked from within constructors.

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

责任编辑:小草

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