問題1:一些類的方法使用不熟練,好比這裏整形和字符串之間的轉換。
html
問題1解決方案:按照書上的例題,本身從新設計一些簡單的程序單獨實驗這些方法的用法。java
問題2:忘記了字符串和ArrayList引索是從0開始排序的,在使用好比charAT()、add(E obj)這樣的方法總會出現這樣的錯誤提示
git
問題2解決方案:當時一直沒能發現爲何錯了,不斷修改各個部分進行嘗試最後才找到錯誤。編程
問題3:在if的嵌套裏面很容易犯錯,好比用錯了大括號或者else對應了錯誤的if
數據結構
問題3解決方案:使用正確的縮進格式頗有必要,在檢查程序時能夠方便更改。編程語言
問題4:在循環語句裏,一些變量賦值的位置不對,一些變量該在循環以外賦值,有些應該隨着循環不斷改變
oop
錯題1
Which of the sets of statements below will add 1 to x if x is positive and subtract 1 from x if x is negative but leave x alone if x is 0?
A . if (x > 0) x++;
else x--;
B . if (x > 0) x++;
else if (x < 0) x--;
C . if (x > 0) x++;
if (x < 0) x--;
else x = 0;
D . if (x == 0) x = 0;
else x++;
x--;
E . x++;
x--;學習
理解狀況:當時對but leave x alone 的理解錯了,因此選了C,應該是無論X了,因此應該是B。ui
錯題2
Assume that count is 0, total is 20 and max is 1. The following statement will do which of the following? if (count != 0 && total / count > max) max = total / count;
A . The condition short circuits and the assignment statement is not executed
B . The condition short circuits and the assignment statement is executed without problem
C . The condition does not short circuit causing a division by zero error
D . The condition short circuits so that there is no division by zero error when evaluating the condition, but the assignment statement causes a division by zero error
E . The condition will not compile because it uses improper syntaxthis
理解狀況:由於一個&&條件的左手邊是假的,條件是短路的,因此右手邊沒有被評估。從而避免了零偏差的可能除法。由於條件是錯誤的,語句Max=total/count沒有執行,一樣避免了零錯誤的潛在除法。因此不選D而是選A。
錯題3
If x is an int where x = 1, what will x be after the following loop terminates?
while (x < 100)
x *= 2;
A . 2
B . 64
C . 100
D . 128
E . none of the above, this is an infinite loop
正確答案: D 你的答案: B
理解狀況:當X=64時仍然小於100,還會再執行一次。
錯題4
Which of the following are true statements about check boxes?
A . they may be checked or unchecked
B . radio buttons are a special kind of check boxes
C . they are Java components
D . you can control whether or not they will be visible
E . all of the above
正確答案: E 你的答案: A
理解狀況:當時不知道複選框,後來仔細看書才知道都是對的。
錯題5
In Java, selection statements consist of the if and if-else statements.
A . true
B . false
正確答案: B 你的答案: A
理解狀況:還應該有switch語句。
錯題6
An if statement may or may not have an else clause, but an else clause must be part of an if statement.
A . true
B . false
正確答案: A 你的答案: B
理解狀況:java容許if語句或if-else語句。但else只能做爲if語句的一部分。
錯題7
The following for-loop is an infinite loop.
for (int j = 0; j < 1000; ) i++;
A . true
B . false
正確答案: A 你的答案: B
理解狀況:此循環將J初始化爲0,並將其與1000進行比較,但在每次循環迭代後不會更改J。實際上,當值太大而沒法存儲在內存中時,循環最終將以運行時錯誤結束,但邏輯上這是一個無限循環。
錯題8
In Java, it is possible to create an infinite loop out of while and do loops, but not for-loops.
A . true
B . false
正確答案: B 你的答案: A
理解狀況:這是真的,而while和do循環能夠是無限循環,但for循環能夠是無限循環。這在許多其餘編程語言中都不是真的,由於for-loops有一個集的起點和結束點,可是java for-loops比大多數其餘語言的for-loops靈活得多。
代碼行數(新增/累積) | 博客量(新增/累積) | 學習時間(新增/累積) | 重要成長 | |
---|---|---|---|---|
目標 | 5000行 | 30篇 | 400小時 | |
第一週 | 189/189 | 1/1 | 18/18 | |
第二週 | 250/439 | 2/3 | 21/39 | |
第三週 | 437/876 | 3/6 | 25/64 | |
第四周 | 659/1535 | 2/8 | 31/95 | |
第五週 | 647/2182 | 1/9 | 30/125 |