9道scjp题310-035解析
2006-11-30 09:47
495 查看
1. Which of the following range of short is correct?
A. -27 -- 27-1
B. 0 -- 216-1
C. ?215 -- 215-1
D. ?231 -- 231-1
翻译下面哪些是short型的取值范围。
答案
C 解析
短整型的数据类型的长度是16 bits,有符号。另外需要说明的是java中所有的整(Integral)数(包括byte,short,int,long)全是有符号的。
2. Which declarations of identifiers are legal?
A. $persons
B. TwoUsers
C. *point
D. this
E. _endline
翻译下面哪些是合法的标识符。
答案
A,B,E 解析
Java的标识符可以以一个Unicode字符,下滑线(_),美元符($)开始,后续字符可以是前面的符号和数字,没有长度限制,大小写敏感,不能是保留字。
google_ad_client = "pub-8112432724706407";
google_ad_width = 728;
google_ad_height = 15;
google_ad_format = "728x15_0ads_al";
google_ad_channel = "";
google_color_border = "FFFFFF";
google_color_bg = "FFFFFF";
google_color_link = "0000FF";
google_color_text = "000000";
google_color_url = "008000";
3. Which statement of assigning a long type variable to a hexadecimal value is correct?
A. long number = 345L;
B. long number = 0345;
C. long number = 0345L;
D. long number = 0x345L
翻译哪些是将一个十六进制值赋值给一个long型变量。
答案
D 解析
十六进制数以0x开头,long型数以L(大小写均可,一般使用大写,因为小写的l和数字1不易区分)。
4.Which of the following fragments might cause errors?
A. String s = "Gone with the wind";
String t = " good ";
String k = s + t;
B. String s = "Gone with the wind";
String t;
t = s[3] + "one";
C. String s = "Gone with the wind";
String standard = s.toUpperCase();
D. String s = "home directory";
String t = s - "directory";
翻译下面的哪些程序片断可能导致错误。
答案B,D 解析
A:String类型可以直接使用+进行连接运算。
B:String是一种Object,而不是简单的字符数组,不能使用下标运算符取其值的某个元素,错误。
C:toUpperCase()方法是String对象的一个方法,作用是将字符串的内容全部转换为大写并返回转换后的结果(String类型)。
D:String类型不能进行减(-)运算,错误。
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 解析
SL-275中指出:要为一个新对象分配空间必须执行new Xxx()调用,new调用执行以下的操作:
1.为新对象分配空间并将其成员初始化为0或者null。
2.执行类体中的初始化。(例如在类中有一个成员声明int a=10;在第一步后a=0 ,执行到第二步后a=10)
3.执行构造函数。
4.变量被分配为一个到内存堆中的新对象的引用。
8. Which of the following answer is correct to express the value 8 in octal number?
A. 010
B. 0x10
C. 08
D. 0x8
翻译
下面的哪些答案可以用以表示八进制值8。
答案
A 解析
八进制值以0开头,以0x开头的为十六进制值,八进制中不能出现数字8,最大只有7。
9. Which are not Java keywords?
A. TRUE
B. sizeof
C. const
D. super
E. void
翻译
哪些不是Java关键字。
答案A,B 解析
A:不是,Java中有true,但是这也不是关键字而是字面量(literal)。
B:不是,Java中不需要这个操作符,所有的类型(原始类型)的大小都是固定的。
C、D、E都是,需要说明的是const是java中未被使用的关键字。
A. -27 -- 27-1
B. 0 -- 216-1
C. ?215 -- 215-1
D. ?231 -- 231-1
翻译下面哪些是short型的取值范围。
答案
C 解析
短整型的数据类型的长度是16 bits,有符号。另外需要说明的是java中所有的整(Integral)数(包括byte,short,int,long)全是有符号的。
2. Which declarations of identifiers are legal?
A. $persons
B. TwoUsers
C. *point
D. this
E. _endline
翻译下面哪些是合法的标识符。
答案
A,B,E 解析
Java的标识符可以以一个Unicode字符,下滑线(_),美元符($)开始,后续字符可以是前面的符号和数字,没有长度限制,大小写敏感,不能是保留字。
google_ad_client = "pub-8112432724706407";
google_ad_width = 728;
google_ad_height = 15;
google_ad_format = "728x15_0ads_al";
google_ad_channel = "";
google_color_border = "FFFFFF";
google_color_bg = "FFFFFF";
google_color_link = "0000FF";
google_color_text = "000000";
google_color_url = "008000";
3. Which statement of assigning a long type variable to a hexadecimal value is correct?
A. long number = 345L;
B. long number = 0345;
C. long number = 0345L;
D. long number = 0x345L
翻译哪些是将一个十六进制值赋值给一个long型变量。
答案
D 解析
十六进制数以0x开头,long型数以L(大小写均可,一般使用大写,因为小写的l和数字1不易区分)。
4.Which of the following fragments might cause errors?
A. String s = "Gone with the wind";
String t = " good ";
String k = s + t;
B. String s = "Gone with the wind";
String t;
t = s[3] + "one";
C. String s = "Gone with the wind";
String standard = s.toUpperCase();
D. String s = "home directory";
String t = s - "directory";
翻译下面的哪些程序片断可能导致错误。
答案B,D 解析
A:String类型可以直接使用+进行连接运算。
B:String是一种Object,而不是简单的字符数组,不能使用下标运算符取其值的某个元素,错误。
C:toUpperCase()方法是String对象的一个方法,作用是将字符串的内容全部转换为大写并返回转换后的结果(String类型)。
D:String类型不能进行减(-)运算,错误。
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 解析
SL-275中指出:要为一个新对象分配空间必须执行new Xxx()调用,new调用执行以下的操作:
1.为新对象分配空间并将其成员初始化为0或者null。
2.执行类体中的初始化。(例如在类中有一个成员声明int a=10;在第一步后a=0 ,执行到第二步后a=10)
3.执行构造函数。
4.变量被分配为一个到内存堆中的新对象的引用。
8. Which of the following answer is correct to express the value 8 in octal number?
A. 010
B. 0x10
C. 08
D. 0x8
翻译
下面的哪些答案可以用以表示八进制值8。
答案
A 解析
八进制值以0开头,以0x开头的为十六进制值,八进制中不能出现数字8,最大只有7。
9. Which are not Java keywords?
A. TRUE
B. sizeof
C. const
D. super
E. void
翻译
哪些不是Java关键字。
答案A,B 解析
A:不是,Java中有true,但是这也不是关键字而是字面量(literal)。
B:不是,Java中不需要这个操作符,所有的类型(原始类型)的大小都是固定的。
C、D、E都是,需要说明的是const是java中未被使用的关键字。
相关文章推荐
- 一位仁兄的学习心得---考试认证:SCJP 310-035考试心得
- JAVA认证:SCJP310-035考试心得
- JAVA认证:SCJP310-035考试心得
- 通往成功的道路在SCJP 5.0 CX-310-055和SCJP 6.0(CX-310-066)认证考试
- SCJP考试题310-025(第二套)51-91/147
- scjp题目解析(五)
- scjp题目解析(十四)
- sun认证 高分过scjp310-055
- SAT句子填空题9道及答案解析
- 错误修订:SCJP认证套题解析之二第40题
- 2012-11-17 SCJP习题解析
- 五月份考一下SCJP 310-065
- SCJP认证套题解析之一
- scjp题目解析(十五)
- SUN认证Java2程序员考试(SCJP)试题解析
- SUN认证Java2程序员考试(SCJP)试题解析
- SCJP考试题310-025(第一套)
- SCJP认证套题解析之一
- scjp题目解析(一)
- SCJP认证套题解析之一