JAVA语言基础之数据类型种类4
② 高级的数据类型转换到低级时,必须强制进行数据类型转换。int a=20;
byte b=(byte)a;//域大者转换为域小者,则应强制转换
要点F
Java中不支持C/C++中的指针(基于安全性考虑)、结构(将类与结构统一,只要类中不包含有方法的定义,便是结构)、联合与枚举等数据类型;无全局变量定义、数组越界为异常错误等。
练习:
1.Which of the following is valid Java identifier?
a) my_id
b) lc%e
c) my-id
d) id101
e) 101id
f) synchronized
g) _id
h) %id
i) #id
j) $id
k) native
2. Which of the following are wrong:
a) 0666
b) xfff
c) 0s78
d) 0586
e) 0x339
f) 9.6e-50
g) 0xfga
h) 2000
i) 0796
j) -e-29
k) 0407
l) 0111
3. identify the data type of the following numbers:
a)55L b)’B’ c)470f d)345D e)076 f)0x76
页:
[1]