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

answer 1)

1) the code will compile and run, printing out the words "my func"

a class that contains an abstract method must be declared abstract itself, but may contain non abstract methods.


answer 2)

4) the code will compile but will complain at run time that main is not correctly defined

in this example the parameter is a string not a string array as needed for the correct main method


answer 3)

1) public
2) private
4) transient

the keyword transient is easy to forget as is not frequently used. although a method may be considered to be friendly like in c++ it is not a java keyword.


answer 4)

2) the compiler will complain that the base class is not declared as abstract.

if a class contains abstract methods it must itself be declared as abstract


answer 5)

1) to get to access hardware that java does not know about
3) to write optimised code for performance in a language such as c/c++


answer 6)

4) success in compilation and output of "amethod" at run time.

a final method cannot be ovverriden in a sub class, but apart from that it does not cause any other restrictions.


answer 7)

4) compilation and execution without error

it would cause a run time error if you had a call to amethod though.

answer 8)

1)compile time error: base cannot be private

a top leve (non nested) class cannot be private.


answer 9)

4) p1 compiles cleanly but p2 has an error at compile time

the package statement in p1.java is the equivalent of placing the file in a different directory to the file p2.java and thus when the compiler tries to compile p2 an error occurs indicating that superclass p1 cannot be found.


answer 10)

2) an error at run time

this code will compile, but at run-time you will get an arrayindexoutofbounds exception. this becuase counting in java starts from 0 and so the 5th element of this array would be i[4].

remember that arrays will always be initialized to default values wherever they are created.


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

责任编辑:小草

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