JAVA认证历年真题:SCJP考试真题和解析(2)
来源:优易学  2011-9-22 19:45:18   【优易学:中国教育考试门户网】   资料下载   IT书店

 

26、Which of the following statements about declaration are true?
  A. Declaration of primitive types such as boolean, byte and so on does not allocate memory space for the variable.

  B. Declaration of primitive types such as boolean, byte and so on allocates memory space for the variable.

  C. Declaration of nonprimitive types such as String, Vector and so on does not allocate memory space for the object.

  D. Declaration of nonprimitive types such as String, Vector ans so on allocates memory space for the object.

  (ad)

  题目:下面的有关声明的哪些叙述是对的。
  A. 对原始数据类型例如boolean,byte的变量的声明不会为该变量分配内存空间。

  B. 对原始数据类型例如boolean,byte的变量的声明将为之分配内存空间。

  C. 非原始数据类型例如String,Vector的变量的声明不会为该对象分配内存。

  D. 非原始数据类型例如String,Vector的变量的声明会为该对象分配内存。

  对原始数据类型的变量的声明将为之分配内存并赋予一个缺省值,参见23题的叙述,而非原始数据类型的变量必须用new Xxxx()分配内存及初始化。但是严格来讲此题的答案有待确定,因为只有原始类型的实例变量和类变量的声明在类对象被创建/类被加载时完成内存的自动分配,而原始类型的局部变量必须显式初始化,从这点来看原始类型的局部变量没有被自动分配内存,SL275中只提出了非原始数据类型的变量必须使用new Xxxx()完成内存的分配而没有指出原始数据类型的变量是否在声明时即自动进行内存分配,而从局部变量不能在显式初始化前使用这点来看在声明时没有进行内存分配。因此答案a的正确性还有待官方的确定。

  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. 在方法中定义的方法的参变量只要该对象被需要就一直存在。

  本题还是讨论变量的类型及作用域,参看前面的叙述。

上一页  [1] [2] [3] [4] [5] [6] [7] [8] [9] [10]  ... 下一页  >> 

责任编辑:小草

文章搜索:
 相关文章
热点资讯
资讯快报
热门课程培训