格林模拟试题二参考答案

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

 

answer 31)

4) compile and run with output of "pausing" and "continuing" after a key is hit

an overriden method in a sub class must not throw exceptions not thrown in the base class. in the case of the method amethod it throws no exceptions and will thus compile without complain. there is no reason that a constructor cannot be protected.


answer 32)

4) compile time error because of the line creating the instance of inner


this looks like a question about inner classes but it is also a reference to the fact that the main method is static and thus you cannot directly access a non static method. the line causing the error could be fixed by changing it to say

        inner i = new outer().new inner();

then the code would compile and run producing the output "inner"


answer 33)

1) error at compile time

if you implement an interface you must create bodies for all methods in that interface. this code will produce an error saying that mywc must be declared abstract because it does not define all of the methods in windowlistener. option 4 is nonsense as comments can appear anywhere. option 3 suggesting that it might compile but not produce output is ment to mislead on the basis that what looks like a constructor is actually an ordinary method as it has a return type.


answer 34)

4) compile time error

an error will be caused by attempting to define an integer as static within a method. the lifetime of a field within a method is the duration of the running of the method. a static field exists once only for the class. an approach like this does work with visual basic.


answer 35)

4)int z = 015;

the letters c and s do not exist as literal indicators and a string must be enclosed with double quotes, not single as in this case.


answer 36)

1)double
4)instanceof

note the upper case s on switch means it is not a keyword and the word then is part of visual basic but not java. also, instanceof looks like a method but is actually a keyword,

视频学习

我考网版权与免责声明

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

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

最近更新

社区交流

考试问答