2009年2月11日 星期三

第98題

Given:
15. public class Yippee{
16. public static void main(String[] args){
17. for(int x = 1; x < args.length; x++){
18. System.out.print(args[x] + " ");
19. }
20. }
21. }
and two separate command line invocations:
java Yippee
java Yippee 1 2 3 4
What is the result?

A. No output is produced. 123
B. No output is produced. 234
C. No output is produced. 1234
D. An exception is thrown at runtime. 123
E. An exception is thrown at runtime. 234
F. An exception is thrown at runtime. 1234
答案:B
參考:8-4 main()方法的參數傳遞與系統屬性設定
-------------------------------------------------------------------
java Yippee //沒傳參數No output is produced.
java Yippee 1 2 3 4 //x從1開始 234

沒有留言:

張貼留言