格林模拟试题一参考答案

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

 

answer 30)

1,2,3

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


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.

视频学习

我考网版权与免责声明

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

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

最近更新

社区交流

考试问答