Hard Multiple Choice QuestionsΒΆ

These problems are harder than most of those that you will usually see on the AP CS A exam.

5-9-1: The following method will return true if and only if:

public boolean check(String s) {
   return s.length() >= 2 && (s.charAt(0) ==
      s.charAt(1) || check(s.substring(1)));
}






5-9-2: Susan is 5 years older than Matt. Three years from now Susan’s age will be twice Matt’s age. What should be in place of the following condition to solve this problem?

for (int s = 1; s <=100; s++) {
   for (int m = 1; m <= 100; m++) {
      if (condition)
         System.out.println("Susan is " + s + " and Matt is " + m);
   }
}






5-9-3: Assuming that x and y have been declared as valid integer values, which of the following is equivalent to this statement?

(x > 15 && x < 18) || (x > 10 || y < 20)