98. argv 與 main() 方法
如果您要傳遞的資訊本身包含有空白 , 可以使用一對
雙引號 (") 將整串字括起來 , 例如:
其中的 this is a text 會被拆解為 4 個單字,如下:
99. argv 與 main() 方法
如果 "this is a text" 是單一項資訊 , 就得使用一對雙
引號括起來:
執行結果如下:
其中 "this is a text" 就被當作是一項資訊 , 而不會被
拆成 this 、 is 、 a 、 text 分開的 4 項資訊了。
104. 1. Which statement s will legally declare and initialize an
array?
A. int [ ] a = {"1","2","3"} ;
B. int [ ] a = {1,2,3} ;
C. int [ ] a = [1,2,3] ;
D. int [ ] [ ] a = {{1},{2},{3}} ;
E. int [ ] [ ] a = {1,2} {3,4} {5,6} ;
F. int [ ] a = new int [ ] {1,2,3} ;
G. int [ ] a = new int [3] {1,2,3} ;
105. 2. Please drag and drop the appropriate code into the
following empty boxes:
Code:
106. 3. Given:
Place the appropriate result to the end of the following two
command line executions:
java ArgShow Place result here
java ArgShow a "b c" d Place result here
108. 4. Given:
Which, inserted at line 4, will compile? (choose three or
four)
A. char a; for(int i=0; i<b.length; i++) { a = b[i];
B. for(b : char a) {
C. for(char a : b) {
D. char a; for(a : b)
E. for(char a, i=0; i<b.length; i++) { a = b[i];
110. 5. Given:
Which statements are true? (Choose all that apply. )
A. Compiles error at L1.
B. Compiles error at L2.
C. Compiles error at L3.
D. Compiles error at L4.
E. Compiles error at L5.
113. Which statements are true? (Choose a l l that apply. )
A. the array referenced by b is eligible for garbage
collection at line 8.
B. the array referenced by b becomes available for
memory-recycling at line 10.
C. the output is "193457".
D. the output is "193458".
E. the output is "123457".
F. the output is "123458".
114. 7. Given:
Which statement is true?
A. This program will not compile.
B. Runtime error at line 5.
C. Runtime error at line 6.
D. The result is 0,0.
E. The result is 0,null.
F. The result is null,null.
116. 8. Which are legal declarations? (Choose all that apply)
A. int[] a = new int[3];
B. int b[3];
C. int c[] = new int[] {1,2,3};
D. int[] d = {1,2,3};
E. int[3] e = {1,2,3};
F. int f[] = new int[3] {1,2,3};