Difficulty: Easy
Correct Answer: CRE
Explanation:
Introduction / Context:
This tests correct use of Substring(startIndex, length) with zero-based indexing.
Given Data / Assumptions:
s1 = "ALL MEN ARE CREATED EQUAL"startIndex = 12, length = 3
Concept / Approach:Substring takes characters starting at startIndex and returns exactly length characters. Indexes are zero-based and include spaces as characters.
Step-by-Step Solution:
Verification / Alternative check:
Print s1[12], s1[13], s1[14] to confirm characters.
Why Other Options Are Wrong:ARE or REA correspond to other ranges; CREATED is too long.
Common Pitfalls:
Off-by-one errors or forgetting spaces count toward indices.
Final Answer:
CRE
Discussion & Comments