SCJP认证套题解析之二

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


 
27、In the Java API documentation which sections are included in a class document?
A. The description of the class and its purpose
B. A list of methods in its super class
C. A list of member variable
D. The class hierarchy
(acd)
题目:在Java API文档中下面的哪些部分被包括在内
A.      类及用途的描述
B.      父类的方法的列表
C.      成员变量的列表
D.     类层次
类文档的内容主要是:类层次、类及用途描述、成员变量列表、构造方法列表、成员方法列表、从类层次上继承的方法列表、成员变量的详细说明、构造方法详细说明、成员方法详细说明。
 
28、Given the following code:
     1) public void modify() {
     2)   int i, j, k;
     3)   i = 100;
     4)   while ( i > 0 ) {
     5)      j = i * 2;
     6)      System.out.println (" The value of j is " + j );
     7)      k = k + 1;
     8)      i--;
     9)   }
     10) }
Which line might cause an error during compilation?
A. line 4
B. line 6
C. line 7
D. line 8
(c)
题目:给出下面的代码:

哪些行在编译时可能产生错误。
这个问题在前面有关变量的类型及其作用域的问题中讨论过,局部变量在使用前必须显式初始化,而代码中的变量k在使用前没有。
 
29、Which of the following statements about variables and scope are true?
A. Local variables defined inside a method are destroyed when the method is exited.
B. Local variables are also called automatic variables.
C. Variables defined outside a method are created when the object is constructed.
D. A method parameter variable continues to exist for as long as the object is needed in which the method is defined.
(abc)
题目:下面有关变量及其作用域的陈述哪些是对的。
A.      在方法里面定义的局部变量在方法退出的时候被撤销。
B.      局部变量也叫自动变量。
C.      在方法外面定义的变量(译注:即实例变量)在对象被构造时创建。
D.     在方法中定义的方法的参变量只要该对象被需要就一直存在。
本题还是讨论变量的类型及作用域,参看前面的叙述。
 
30、A class design requires that a member variable cannot be accessible directly outside the class. Which modifier should be used to obtain the access control?
A. public
B. no modifier
C. protected
D. private
(d)
题目:类的设计要求它的某个成员变量不能被外部类直接访问。应该使用下面的哪些修饰符获得需要的访问控制。
这个在前面也有叙述,java有四种访问类型,分别为:public,protected,default,private,其中public变量可以被所有的外部类访问,而pretected的可以被同一个包及该类的子类访问,default即没有任何修饰符的变量可以被同一个包中的类访问,而private变量只能在被该类内部被访问。题目中的外部类应该理解为除该类自身的所有其它类,因此只有使用private可以达到要求。

视频学习

我考网版权与免责声明

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

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

最近更新

社区交流

考试问答