当前位置:

JAVA认证历年真题:SCJP认证试题解析2

发表时间:2014/4/21 10:15:34 来源:互联网 点击关注微信:关注中大网校微信
关注公众号

5. Which are syntactically valid statement at// point x?

class Person {

private int a;

public int change(int m){ return m; }

}

public class Teacher extends Person {

public int b;

public static void main(String arg[]){

Person p = new Person();

Teacher t = new Teacher();

int i;

// point x

}

}

A. i = m;

B. i = b;

C. i = p.a;

D. i = p.change(30);

E. i = t.b.

翻译 在// point x处的哪些申明是句法上合法的。

答案D,E 解析

A:m没有被申明过,不能使用。

B:虽然b是类Teacher的public成员变量,但是在静态方法中不能使用类中的非静态成员。

C:a是类Person的private成员,在类外不能直接引用。

D:change(int m)方法是public方法,并且返回一个int型值,可以通过类的实例变量p引用并赋值给一个int型变量。

E:b是类Teacher的public成员变量,且是int型,可以通过类的实例变量t引用并赋值给一个int型变量。

6. Which layout manager is used when the frame is resized the buttons′s position in the Frame might be changed?

A. BorderLayout

B. FlowLayout

C. CardLayout

D. GridLayout

翻译 当Frame的大小被改变时Frame中的按钮的位置可能被改变时使用的哪一个布局管理器。

答案

B 解析

A:该布局管理器将容器划分为五个部分,容器大小的改变不会影响其中的组件的位置而是影响他们的大小。

B:该布局管理器根据放入其中的组件的最合适大小调整组件的位置,根据组件放入的顺序安排,一行不能容纳时放入下一行,因此容器的大小改变可能改变组件的位置。

C:该布局管理器显示放入该容器的当前页中的组件,一次显示一个,容器大小的改变不能影响其中组件的位置。

D:该布局管理器将容器划分为固定的网格,组件加入后占据一个单元,各组件的相对位置不会因为容器的大小变化而变化,改变的只是组件的大小。

7. Given the following code fragment:

1) public void create() {

2) Vector myVect;

3) myVect = new Vector();

4) }

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

翻译

给出下面的代码片断。。。下面的哪些陈述为true(真)?

A. 第二行的声明不会为变量myVect分配内存空间。

B. 第二行的声明分配一个到Vector对象的引用的内存空间。

C. 第二行语句创建一个Vector类对象。

D. 第三行语句创建一个Vector类对象。

E. 第三行语句为一个Vector类对象分配内存空间。

答案A,D,E 解析

相关链接JAVA认证考试报考指南  考试论坛 考试知道   考试动态

(责任编辑:fky)

2页,当前第1页  第一页  前一页  下一页
最近更新 考试动态 更多>

考试科目