Problem 1
| Initialize String[] | 2 |
| For loop | 3 |
| Return | 2 |
Problem 2 — 2 points each part
| Appropriate instance or class | 0.8 |
| Method name | 0.4 |
| Argument 1 | 0.4 |
| Argument 2 | 0.4 |
Problem 3 — 1 point each part
Problem 3
There are eleven tokens.
0.4 pts per token, except the three tokens
of (int) are 0.8 points total.
s
=
"CAT"
+
3.5
+
(
int
)
x
;
There are six subexpressions.
0.5 pts deducted for each missed or mislabeled expression.
"CAT"
3.5
"CAT" + 3.5
x
(int) x
"CAT" + 3.5 + (int) x
Problem 4
1.4 points for each of the first five and
3 points for each of the last three.
Problem 5
| if | 3 |
| recursive return | 4 |
| else | 1 |
| base return | 2 |
Problem 6
| header | 4 |
| initialize sum | 2 |
| for loop control | 3 |
| for loop body | 2 |
| return | 1 |
Problem 7
| declaration of pts | 4 |
| outer for loop control | 2 |
| inner for loop control | 2 |
| element creation | 4 |
Problem 8
| try-catch | 4 |
| creation of sockAddr | 4 |
| printing hostname | 2 |
| printing error message | 2 |