1. Read through the code 2. Infer that code counts the number of common elements in the two sorted arrays 3. Count manually that number in the two given arrays, namely 3 4. Conclude that option a) is correct Figure 2: Plausible Solution Plan to Question in Figure 1 We notice that counting common elements in sorted arrays is basically the intended function which is implemented by the Java code. As we can judge by seeing the plan of Figure 2, to be able to reach such kind of inference is recognized as an advanced skill for programmers at the level of a CS1 course. Apparently, such a skill is here being exercised.

However, the question hides a little trick, a further difficulty which might be easy to overlook: the array indexes i1 and i2 do not reach the value 0 which in Java is the first index of an array, as known. So the correct answer is actually b). According to the authors 65% answered correctly, but  21% chose a).  This is an extremely interesting empirical result which is further analyzed in detail by the source using the SOLO Taxonomy, which is worthy to read but is currently beyond our scope.

Let us recapitulate some key ideas from the example. The solution procedure shown above would match the solving-plan that a relative experienced programmer would apply by means of concept/role assignment techniques in order to recover the intended function
(see [5, 30]). In contrast, another less experienced responder would probably use a strategy of a lower cognitive level, essentially by executing the fragment and obtaining the right answer more or less mechanically ([48]). Probably, without having grasped the intended function, so without needing to understand the code at the abstract level. Thus, the less experienced programmer would get a better performance than the more experienced one, who fell into the trap of the trick.

The question is which level of complexity is mainly being exercised: recovering the intention or applying the concrete operational semantics of arrays and loops. If recovering was the goal, maybe 65% of correct answers is not properly reflecting it. If both area were aimed at by exercise, we learn that adding such a small piece of complexity might yield a potentially unexpected result. Tricks like these seen here are known as distractors. They turn out useful in exposing some misconceptions or uncovering incomplete learning. They should be consistent with the complexity of the test, however.