Independent Software Vendor
1
SCJP 试题集及解析
1. Which of the following range of short is correct?
A. -2
7
-- 2
7
-1
B. 0 – 2
16
-1
C. 2
15
– 2
15
-1
D. 2
31
– 2
31
-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 字符,下滑线(_),美元符($)开始,
后续字符可以是前面的符号和数字,没有长度限制,大小写敏感,不能是保留字。
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";