Page 1239 - AP Computer Science A, 7th edition
P. 1239

25. (B) Segment II correctly checks that the part descriptions match and keeps track of the current part with minimum price. If this is not done, the part whose number must be returned will be lost. Segment I is incorrect because it doesn’t check that partDescription matches the description of the current part being examined in the array. Thus, it simply finds the AutoPart with the lowest price, which is not what was required. Segment III incorrectly returns the part number of the first part it finds with a matching description.


































































































   1237   1238   1239   1240   1241