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

 

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,

answer 37)

4) -3.0


answer 38)

3) one

command line parameters start from 0 and from the first parameter after the name of the compile (normally java)


answer 39)

4) the set is designed for unique elements.

collection is an interface, not a class. the collection interface includes a method called iterator. this returns an instance of the iterator class which has some similarities with enumerators.
the name set should give away the purpose of the set interface as it is analogous to the set concept in relational databases which implies uniquness.


answer 40)

2) if multiple listeners are added to a component the events will be processed for all but with no guarantee in the order
4) you may remove as well add listeners to a component.

it ought to be fairly intuitive that a component ought to be able to have multiple listeners. after all, a text field might want to respond to both the mouse and keyboard


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

责任编辑:小草

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