Exam Solutions: =============== 1a) Use .equals() when comparing two *objects* for equality. Use == to compare primitive types (e.g. int), or to check whether two object references point to the same object in memory. 1b) Declare a variable as local if it's only used in a single method. This will reduce the complexity of your code, and eliminate bugs that might arise from unrelated pieces of code accidentally changing an instance variable. 1c) In a count-controlled loop we know exactly how many times we want to repeat some operation, and we can use a counter variable to keep track of where we are in the process and when to stop. An event-controlled loop is one where we don't know how many iterations it will take, but we know when we're done. (E.g. we keep guessing at combinations until we find the right one.) 2a) The method takes two Die instances and rolls them until the difference in the sum of d1's rolls and the sum of d2's rolls is 10 or greater. It returns the number of rolls required until that difference is achieved. 2b) If the two Die instances have different numbers of sides we would expect the loop to run fewer times in general, since the difference should grow more quickly in that case. 3) public int sumRandomlySelectedValues (int[] nums, int n) { Random rng = new Random(); int sum = 0; for(int i=0; i getNotesContaining(String txt) { ArrayList list = new ArrayList(); for(String s : notes) { if (s.contains(txt)) { list.add(s); } } return list; }