Java 1
3.1 num = 3 ch = 'C' 2
final 3.1 final : final final double PI=3.1415926; 3
3.2 4
int 3.2 (long int) (int) (short int) (byte) short sum; // sum 5
3.2 Java int long num=32967359818l; C:\java\app3_2.java:6: integer number too large: 32967359818 long num=32967359818; 6
3.2 (1/3) 7
3.2 (2/3) 8
3.2 (3/3) 9
(overflow) (1/3) 3.2 10
(overflow) (2/3) 3.2 11
(overflow) (3/3) int 3.2 12
app3_5 13
3.2 (1/2) 2 Java Unicode( ) char ch; ch='a'; // ch // 'A' ch char ch1='a'; char ch2=97; char ch3='7'; // ch1 'A' // ch2 ASCII 97 // ch3 '7' 14
(1/2) 3.2 15
(1/2) 3.2 \ \ 16
(2/2) 3.2 char ch2=074; char ch3=0x3e; 17
, : "Java " 18
(1/3) float 4 double 8 3.2 float double double num; float sum=2.0f; // num // sum 2.0 19
(2/3) float double double num1=-5.6e64; // num1 double double num2=-6.32e16; // e E float num3=2.478f; // num3 float 2.478 float num4=2.63e64; // float 3.2 20
3.2 (3/3) float double 21
PI=3.14159 r area =? =? 22
3.2 boolean status=true; // status true 23
3.3 (1/2) (1) (2) int float int float char int char int augmented conversion 24
3.3 (2/2) 25
(1/3) 3.3 explicit cast 26
(2/3) 3.3 a/(float)b a b (float)a/(float)b 27
(3/3) narrowing conversion Java 3.3 28
3.4 (1/4) 29
3.4 (2/4) 30
3.4 (3/4) int 31
3.4 (4/4) method 32
'U' Exception in thread "main" java.lang.numberformatexception: For input string: "U" at java.lang.numberformatexception.forinputstring(numberformatexception.java:48) at java.lang.integer.parseint(integer.java:447) at java.lang.integer.parseint(integer.java:497) at app3_14.main(app3_14.java:15) 3.4 33
3.4 34
app3_15 35
Given: Which lines will cause compilation error? (Choose all that apply.) A. Line 3 B. Line 4 C. Line 5 D. Line 6 E. Line 7 36
37
Given: What is the result? A. str = "" B. str = null C. str = D. Compile fails. E. An Exception is thrown at runtime. 38
Which are Primitive data types? (Choose all that apply.) A. Char B. String C. bit D. int E. boolean F. Short G. long 39
Which two of following declarations are illegal? A. S1 B. S2 C. S3 D. S4 E. S5 F. S6 40
41
42