2009年2月11日 星期三

第110題

Given:
11. public static void test(Sting str){
12. int check = 4;
13. if(check = str.length()){
14. System.out.print(str.charAt(check -= 1) + ", ");
15. }else{
16. System.out.print(str.charAt(O) + ", ");
17. }
18. }
and the invocation:
21. test("four");
22. test("tee");
23. test("to");
What is the result?
A. r, t, t,
B. r, e, o,
C. Compilation fails.
D. An exception is thrown at runtime.
答案:C
參考:4-1 條件控制、8-2 方法種類與呼叫方式
------------------------------------------------------------
13. if(check = str.length()){ //if(check == str.length())

沒有留言:

張貼留言