Unit 1 Cycle 2 Day 25: I/II/III: Mixed Concepts
Share
I/II/III: Mixed Concepts
Section Mixed — Review: All Unit 1
Key Concept
I/II/III mixed concept questions pull from across all of Unit 1, testing whether you can switch between different rule sets rapidly. One statement might test integer division, another string comparison, and a third casting behavior. The AP exam deliberately mixes familiar concepts to test whether your knowledge is robust or fragile. The best approach is to treat each statement as a completely separate mini-problem, evaluating it with fresh attention rather than being influenced by your assessment of the other statements.
Consider the following statements.
Which of the statements are correct?
Answer: (A) II only
Evaluate each statement:
I: INCORRECT. Math.random() returns [0.0, 1.0). The maximum is just under 1.0, so Math.random() * 10 is just under 10.0. (int) of that is 9. The value 10 is never produced.
II: CORRECT. "abc".substring(3) starts at index 3, which equals the length. This returns the empty string "", which is valid (no exception).
III: INCORRECT. With autoboxing, Java caches Integer values from -128 to 127. For 128, Java creates new objects, so x == y compares different references and is false. This is NOT guaranteed to be true.
Why Not the Others?
(B) Statement I is incorrect. (int)(Math.random() * 10) produces 0-9, never 10.
(C) Statement III is incorrect. Integer caching only guarantees == works for values -128 to 127. For 128, separate objects may be created.
(D) Only Statement II is correct. Both I and III are common misconceptions.
Common Mistake
Three distinct traps: (1) Math.random() never reaches 1.0, so (int)(Math.random() * n) produces 0 to n-1. (2) substring(length) is valid and returns empty string. (3) Integer autoboxing caches small values but not large ones like 128.
AP Exam Tip
This question tests three separate Unit 1 concepts. The AP exam frequently combines topics in I/II/III format. Evaluate each independently and do not assume patterns across statements.