java基础考试题及答案.docx
- 184****7392个人认证 |
- 2021-11-27 发布|
- 67.12 KB|
- 18页
java基础考试题及答案
java基础考试题及答案
PAGE / NUMPAGES
java基础考试题及答案
新员工考试
一、 选择题(共 30 题,每题 2 分)
下面哪些是合法的标识符 ?(多选题)
$persons
TwoUsers
*point
this
E. _endline
答案 A,B,E
分析 Java 的标识符可以以一个 Unicode 字符,下滑线( _),美元符( $)开始,后续字符可以是前面的符号和数字,没有长度限制,大小写敏感,不能是保留字( this 保留字)。
哪些是将一个十六进制值赋值给一个 long 型变量 ?(单选题)
long number = 345L;
long number = 0345;
long number = 0345L;
long number = 0x345L
答案 D
分析 十六进制数以 0x 开头,long 型数以 L(大小写均可, 一般使用大写,因为小写的 l 和数字 1 不易区分)。
下面的哪些程序片断可能导致错误 ? (多选题)
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