可学答题网 > 问答 > SCJP程序员认证考试题库
目录: 标题| 题干| 答案| 搜索| 相关
问题

Given the following co


Given the following code fragment:     public void create() {     Vector myVect;     myVect = new Vector();      }  Which of the following statements are true?() 

  • A The declaration on line 2 does not allocate memory space for the variable myVect.
  • B The declaration on line 2 allocates memory space for a reference to a Vector object.
  • C The statement on line 2 creates an object of class Vector.
  • D The statement on line 3 creates an object of class Vector.
  • E The statement on line 3 allocates memory space for an object of class Vector.
参考答案
参考解析:

SL-275中指出:要为一个新对象分配空间必须执行new Xxx()调用,new调用执行以下的操作: 1.为新对象分配空间并将其成员初始化为0或者null。 2.执行类体中的初始化。(例如在类中有一个成员声明int a=10;在第一步后a=0 ,执行到第二步后a=10)    3.执行构造函数。 4.变量被分配为一个到内存堆中的新对象的引用。

分类:SCJP程序员认证考试题库
相关推荐

1、Given the following sc

Given the following scripts, both found in /usr/local/bin, what would the output be when exec...

2、Given the following in

Given the following interface definition, which definitions are valid?()  interface I {  vo...

3、Given the following co

Given the following code:   public class Test { void printValue(int m){ do { System.out...

4、Given the following co

Given the following code, which code fragments, when inserted at the indicated location, will&ens...

5、Given the following co

Given the following code:    public class Person{    int arr[] = new int[10];&...

6、Given the following co

Given the following code:    public class Person{ static int arr[] = new int[10]; p...