下面编译出现错误的是
A. byte a=0b10000000;
B. short b=128+128
C. int c=2 *3L
D. float d=10.0;
答案ACD
解答:
A. 0b10000000是二进制的128 ,byte 可以存储的范围是-128 ~127,128>127会编译失败
C.long⇒integer,会编译失败
D. 10.0是double,double⇒float ,会编译失败
B.short 可以存储的范围是 -32768~ 32767
Data Type | Size | Description |
byte | 1byte | Stores whole numbers from -128 to 127 |
short | 2bytes | Stores whole numbers from -32768 to 32767 |
int | 4bytes | Stores whole numbers from -2147483648 to2147483647 |
long | 8bytes | Stores whole numbers from -92233272036854775808 to 92233272036854775807 |
float | 4bytes | Stores fractional numbers. Sufficient for storing 6 to 7 decimal digits |
double | 8bytes | Stores fractional numbers. Sufficient for storing 15 decimal digits |
boolean | 1bit | Stores true or false values |
本文到此结束