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

 

answer 41)

3) 10 and 40

when a parameter is passed to a method the method receives a copy of the value. the method can modify its value without affecting the original copy. thus in this example when the value is printed out the method has not changed the value.


answer 42)

4) for(int i=0; i< ia.length;i++)

although you could control the looping with a literal number as with the number 4 used in option 3, it is better practice to use the length property of an array. this provides against bugs that might result if the size of the array changes. this question also checks that you know that arrays starts from zero and not one as option 3 starts from one. remember that array length is a field and not a function like the string length() method.


answer 43)

1) error at compile time

this is a slightly sneaky one as it looks like a question about constructors, but it is attempting to test knowledge of the use of the private modifier. a top level class cannot be defined as private. if you didn't notice the modifier private, remember in the exam to be real careful to read every part of the question.


answer 44)

3)10

the name of the class might give you a clue with this question, oct for octal. prefixing a number with a zero indicates that it is in octal format. thus when printed out it gets converted to base ten. 012 in octal means the first column from the right has a value of 2 and the next along has a value of one times eight. in decimal that adds up to 10.


answer 45)

1) error at compile time

the variable i is created at the level of amethod and will not be available inside the method multi. 
 


answer 46)

1) set

the set interface ensures that its elements are unique, but does not order the elements. in reality you probably wouldn't create your own class using the set interface. you would be more likely to use one of the jdk classes that use the set interface such as hashset or treeset.

answer 57)

4) a collection for storing bits as on-off information, like a vector of bits

this is the description given to a bitset in bruce eckels "thinking in java" book. the reference to unique sequence of bits was an attempt to mislead because of the use of the word set in the name bitset. normally something called a set implies uniqueness of the members, but not in this context.


answer 58)

4)compile error: superclass class1.base of class class1.class1 not found

using the package statement has an effect similar to placing a source file into a different directory. because the files are in different packages they cannot see each other. the stuff about file1 not having been compiled was just to mislead, java has the equivalent of an "automake", whereby if it was not for the package statements the other file would have been automatically compiled.


answer 59)

4) output of over.amethod()

the names of parameters to an overridden method is not important, but as the version of amethod in class base is set to be private it is not visible within over (despite over extending base) and thus does not take part in overriding. 
 


answer 60)

1) set the gridy value of the gridbagconstraints class to a value increasing from 1 to 4

answer 4 is fairly obviously bogus as it is the gridbagconstraints class that does most of the magic in laying out components under the gridbaglayout manager. the fill value of the gridbagconstraints class controls the behavior inside its virtual cell and the ipady field controls the internal padding around a component.

if you have a copy of the roberts and heller java2 guide that says the exam does not cover the gridbaglayout, this is an error. you can confirm this by looking at the online errata at

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

责任编辑:小草

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