| CIT594 First Quiz Fall, 2003 |
Name_________________________________________ |
Please answer all questions briefly and to the point. You have plenty of room for correct answers.
Part I: Eclipse (30 points)
Rename... is one refactoring provided by Eclipse.
Name another.| Move | Encapsulate field | Extract interface | Extract method | Inline |
| Push down | Convert anonymous class to nested | Use supertype where possible | Extract local variable | Extract constant |
| Pull up | Convert nested type to top level | Convert local variable to field | Change method signature |
assertEquals(___,
___), which object should be first?assert..."
test methods (other than assertEquals).setUp() method used for?(), ((())), and (()(())). Unbalanced
strings should be rejected. You can assume the strings contain no other characters
but parentheses.Set I |
TreeSet C |
Iterator I |
Stack C |
Comparator I |
Comparable I |
Collections
interface.Iterator interface.| (best) |
|
(worst)
|
static int getIt(int[] a) {
int target = a[0];
for (int i = 1; i < a.length; i++) {
if (a[i] > target) return i;
}
return -1;
}
|
O(1) Because for a random value a[0], there is a 50% chance of any other value being larger. Average time to find a larger value = 2 tries. |

public BinaryTree copyTree(BinaryTree bt) {
if (bt == null) return null;
BinaryTree leftSide = copyTree(bt.leftChild);
BinaryTree rightSide = copyTree(bt.rightChild);
return new BinaryTree(bt.value, leftSide, rightSide);
}
Set methods corresponding to: